An easy guide to object rest/spread properties in JavaScript

Merging multiple JavaScript objects is a frequent task. Unfortunately JavaScript is sloppy at providing a convenient syntax to do the merge. At least until now. In ES5 your solution is _.extend(target, [sources]) from Lodash (or any alternative), and ES2015 introduces Object.assign(target, [sources]). Luckily object spread syntax (an ECMASript proposal at stage 3) is a step forward how to manipulate objects, providing a… Continue reading

Why object literals in JavaScript are cool

Before ECMAScript 2015 object literals (also named object initializers) in JavaScript were quite elementary. It was possible to define 2 types of properties: Pairs of property names and related values { name1: value1 } Getters { get name(){..} } and setters { set name(val){..} } for computed property values Sadly, the object literal possibilities match into a single example: Try in JS Bin var myObject = { myString: 'value 1', get myNumber(… Continue reading