ES6: Is it dangerous to delete elements from Set/Map during Set/Map iteration?

Yes, you can simplify to that, it’s totally safe. Sets and Maps are always iterated in insertion order Deleting an item does not affect the position of any iterator – you can visualise the shape of the collection not being changed, just being emptied. So: elements that are deleted and have not yet been iterated … Read more

Loop through array of values with Arrow Function [closed]

In short: someValues.forEach((element) => { console.log(element); }); If you care about index, then second parameter can be passed to receive the index of current element: someValues.forEach((element, index) => { console.log(`Current index: ${index}`); console.log(element); }); Refer here to know more about Array of ES6: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

What’s the purpose of `Object.defineProperty(exports, “__esModule”, { value: !0 })`?

It helps to correctly import a default export in CommonJS/AMD/UMD module format. A default import (i.e. import d from “foo”) for a CommonJS/AMD/UMD module is equivalent to const d = require(“foo”).default But most of the CommonJS/AMD/UMD modules available today do not have a default export, making this import pattern practically unusable to import non-ES modules … Read more

Do let statements create properties on the global object?

Do let statements create properties on the global object? According to the spec, no: A global environment record is logically a single record but it is specified as a composite encapsulating an object environment record and a declarative environment record. The object environment record has as its base object the global object of the associated … Read more

ES2015/2016 way of ‘typeof varName === ‘undefined`?

Just check for varName === undefined. In older browsers it was possible to assign an alternate value to the global undefined variable causing that test to fail, but in ES2015+ that’s now impossible. Note that there’s no way to distinguish explicitly passing undefined as a parameter from leaving the parameter out altogether other than by … Read more