2016-11

Why does this work? [].concat[1,2,3]

[2016-11-12] dev, javascript

In this blog post, we look at a syntactic puzzle. This is just for fun; there is nothing useful you can do with what we examine. It may, however, make you more aware of how JavaScript works, syntactically.

Pitfall: not all objects can be wrapped transparently by proxies

[2016-11-12] dev, javascript, esnext, js proxies

A proxy object can be seen as intercepting operations performed on its target object – the proxy wraps the target. The proxy’s handler object is like an observer or listener for the proxy. It specifies which operations should be intercepted by implementing corresponding methods (get for reading a property, etc.). If the handler method for an operation is missing then that operation is not intercepted. It is simply forwarded to the target.

Therefore, if the handler is the empty object, the proxy should transparently wrap the target. Alas, that doesn’t always work, as this blog post explains.

Computing tag functions for ES6 template literals

[2016-11-01] dev, javascript, esnext, template literals

This blog post describes what you can do with functions that return tag functions for ES6 template literals.

For an introduction to template literals, tagged template literals and tag functions, consult chapter “Template literals” in “Exploring ES6”.

2016-10

Three ways of understanding Promises

[2016-10-27] dev, javascript, esnext

This blog post covers three ways of understanding Promises.

Tips for using async functions (ES2017)

[2016-10-22] dev, javascript, esnext

This blog post gives tips for using async functions. If you are unfamiliar with them, you can read chapter “Async functions” in “Exploring ES2016 and ES2017”.

ES2018: asynchronous iteration

[2016-10-02] dev, javascript, esnext, async, es2018

This blog post explains the ECMAScript proposal “Asynchronous Iteration” by Domenic Denicola and Kevin Smith. It has reached stage 4 on 2018-01-25 and is part of ECMAScript 2018.

ES2018: Rest/Spread Properties

[2016-10-02] dev, javascript, esnext, es2018

The ECMAScript proposal “Rest/Spread Properties” by Sebastian Markbåge enables:

  • The rest operator (...) in object destructuring. At the moment, this operator only works for Array destructuring and in parameter definitions.

  • The spread operator (...) in object literals. At the moment, this operator only works in Array literals and in function and method calls.

2016-09

ES proposal: global

[2016-09-29] dev, javascript, esnext, es proposal

The ECMAScript proposal “global” by Jordan Harband is currently at stage 3. It provides a new standard way of accessing the global object.

Improving the syntax of EJS templates

[2016-09-10] dev, javascript

I really like the way EJS templates work, because the meta-language (loops, if-then-else, etc.) is just JavaScript. This blog post describes ideas for improving their syntax.

Three useful Babel presets

[2016-09-10] dev, javascript, babel, esnext

As of version 6, Babel supports presets, sets of features that can be enabled together. This blog post looks at three new useful Babel presets (and, as a bonus, two presets especially for Node.js).