Skip to content

Instantly share code, notes, and snippets.

@KKrisu
Created May 12, 2016 19:55
Show Gist options
  • Save KKrisu/69bafae2bae7a67d373afdb3900f595a to your computer and use it in GitHub Desktop.
Save KKrisu/69bafae2bae7a67d373afdb3900f595a to your computer and use it in GitHub Desktop.
ES6 Maps & Sets
parent.console.clear();
let o1 = {a: 1};
let o2 = {a: 1};
let o = {};
o[34] = 'a';
o['34'] = 'a';
o[o1] = 'b';
o[o2] = 'c';
console.log(o);
let m = new Map();
m.set(34, 'a');
m.set('34', 'b');
m.set(document.getElementsByTagName('body')[0], 'c');
m.set(o1, 'd');
m.set(o2, 'e');
o1.a = 2;
console.log(...m);
let a = [];
if (a.indexOf(1) < 0) {
a.push(1);
}
if (a.indexOf(1) < 0) {
a.push(1);
}
// console.log(a);
let s = new Set();
s.add(1);
s.add(1);
s.add(1);
s.add(1);
s.add(2);
// console.log(...s);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment