First item from a Map on JavaScript ES2015

Use the Map.prototype.entries function, like this const m = new Map(); m.set(‘key1’, {}) m.set(‘keyN’, {}) console.log(m.entries().next().value); // [ ‘key1’, {} ] If you want to get the first key, then use Map.prototype.keys, like this console.log(m.keys().next().value); // key1 Similarly if you want to get the first value, then you can use Map.prototype.values, like this console.log(m.values().next().value); // … Read more

Keyword ‘const’ does not make the value immutable. What does it mean?

When you make something const in JavaScript, you can’t reassign the variable itself to reference something else. However, the variable can still reference a mutable object. const x = {a: 123}; // This is not allowed. This would reassign `x` itself to refer to a // different object. x = {b: 456}; // This, however, … Read more