What does curly brackets in the `var { … } = …` statements do?

What you’re looking at is a destructuring assignment. It’s a form of pattern matching like in Haskell. Using destructuring assignment you can extract values from objects and arrays and assign them to newly declared variables using the object and array literal syntax. This makes code much more succinct. For example: var ascii = { a: … Read more

Why does javascript ES6 Promises continue execution after a resolve?

JavaScript has the concept of “run to completion”. Unless an error is thrown, a function is executed until a return statement or its end is reached. Other code outside of the function can’t interfere with that (unless, again, an error is thrown). If you want resolve() to exit your initializer function, you have to prepend … Read more

Home does not contain an export named Home

The error is telling you that you are importing incorrectly. Here’s the code you have to add: import { Home } from ‘./layouts/Home’; This is incorrect because you’re exporting as the default export, not as a named export. Check this line: export default Home; You’re exporting as default, not as a name. Thus, import Home … Read more

ES6 export all values from object

I can’t really recommend this solution work-around but it does function. Rather than exporting an object, you use named exports each member. In another file, import the first module’s named exports into an object and export that object as default. Also export all the named exports from the first module using export * from ‘./file1’; … Read more

Using map() on an iterator

The simplest and least performant way to do this is: Array.from(m).map(([key,value]) => /* whatever */) Better yet Array.from(m, ([key, value]) => /* whatever */)) Array.from takes any iterable or array-like thing and converts it into an array! As Daniel points out in the comments, we can add a mapping function to the conversion to remove … Read more