Jump to content

JavaScript: Difference between revisions

200 bytes added ,  22 January 2020
No edit summary
Line 76: Line 76:
==Data Structures==
==Data Structures==
JavaScript traditionally has arrays and objects (hashmap) data structures.<br>
JavaScript traditionally has arrays and objects (hashmap) data structures.<br>
ES2015 (ES6) adds several collections including: Map, Set, WeakMap, WeakSet
ES2015 (ES6) adds several collections including: Map, Set, WeakMap, WeakSet<br>
[https://www.sitepoint.com/es6-collections-map-set-weakmap-weakset/ ES6 Collections]


===Arrays===
===Arrays===
Line 98: Line 99:
let my_map = {};
let my_map = {};
my_map["my_key"] = "my_value";
my_map["my_key"] = "my_value";
"my_key" in my_map;


// Loop over keys
for (let key in a) {
  console.log("Key:", key);
}
</syntaxhighlight>
</syntaxhighlight>
===Map===
===Set===


==Modules==
==Modules==