What is the motivation for bringing Symbols to ES6?

The original motivation for introducing symbols to Javascript was to enable private properties. Unfortunately, they ended up being severely downgraded. They are no longer private, since you can find them via reflection, for example, using Object.getOwnPropertySymbols or proxies. They are now known as unique symbols and their only intended use is to avoid name clashes … Read more

When should I use arrow functions in ECMAScript 6?

A while ago our team migrated all its code (a mid-sized AngularJS app) to JavaScript compiled using Traceur Babel. I’m now using the following rule of thumb for functions in ES6 and beyond: Use function in the global scope and for Object.prototype properties. Use class for object constructors. Use => everywhere else. Why use arrow … Read more

One-liner to take some properties from object in ES 6

Here’s something slimmer, although it doesn’t avoid repeating the list of fields. It uses “parameter destructuring” to avoid the need for the v parameter. ({id, title}) => ({id, title}) (See a runnable example in this other answer). @EthanBrown’s solution is more general. Here is a more idiomatic version of it which uses Object.assign, and computed … Read more