It's difficult to explain the case by words, let me give an example:  var myObj = {     'name': 'Umut',     'age' : 34 };  var prop = 'name'; var value = 'Onur';  myObj[name] = value; // This does not wor...
I'm looking for a decent implementation of a set data structure in JavaScript. It should be able to support elements that are plain JavaScript objects.  So far I only found Closure Library's structs.Set, but I don't like the fact that i...
I just want to check that an object is a Map or Set and not an Array.  to check an Array I'm using lodash's _.isArray.  function myFunc(arg) {   if (_.isArray(arg)) {     // doSomethingWithArray(arg)   }    if (isMap(arg)) {     // doSometh...
It maybe because Sets are relatively new to Javascript but I haven't been able to find an article, on StackO or anywhere else, that talks about the performance difference between the two in Javascript. So, what is the difference, in terms of pe...
How do you compare two javascript sets? I tried using == and === but both return false.  a = new Set([1,2,3]); b = new Set([1,3,2]); a == b; //=> false a === b; //=> false   These two sets are equivalent, because by definition, sets do not ha...
Basically, I'm trying to create an object of unique objects, a set. I had the brilliant idea of just using a JavaScript object with objects for the property names. Such as,  set[obj] = true;   This works, up to a point. It works great with string...
Is there any way to map/reduce/filter/etc a Set in JavaScript or will I have to write my own?  Here's some sensible Set.prototype extensions  Set.prototype.map = function map(f) {   var newSet = new Set();   for (var v of this.values()) newSet.ad...
I'm trying to accomplish some animation with sets in Raphael, but even though an opacity animation worked, I cannot succeed in moving a set (or even a circle) around the canvas.  I found on the Web that moving a set should be done with setting tr...
In Eloquent JavaScript, Chapter 4, a set of values is created by creating an object and storing the values as property names, assigning arbitrary values (e.g. true) as property values. To check if the value is already contained in the set, the in ope...
Why does JavaScript have two different ways to get/set object properties?  Example:  //implementation 1 var obj1 = {   "x":1,   get number() {return this.x},   set number(n) {this.x = n} }  //implementation 2 var obj2 = {   "x":1,   g...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.