JavaScript: Remove a property from an object immutably by destructuring it

Say you have a JavaScript object like this: const user = { firstName: ‘Bramus’, lastName: ‘Van Damme’, twitter: ‘bramus’, city: ‘Vinkt’, email: ‘[email protected]’, }; And now say you want to create a copy of the whole object, containing all properties except for the email property. The oldskool way: The first idea that came to my […]

ESNext: JavaScript “Optional Chaining Operator”

UPDATE December 2019: This feature has now advanced to Stage-4 and will be part of the ES2020 Specification! 🎉 UPDATE: The proposed operator got renamed from “Null Propagation Operator” to “Optional Chaining Operator”. This post has been updated to include this change. Earlier today I was delighted to see that the “Optional Chaining Operator” in […]

ES6 ES2015: Looping over an Object with keys and values

Say you have an object like this: const obj = { firstName: ‘John’, lastName: ‘Doe’, age: 50, eyeColor: ‘blue’ }; Using lodash’s forEach you can easily loop over this object, with easy access to both the key and the value: _.forEach(obj, function(value, key) { console.log(key + ‘ ‘ + value); }); But what about ES2015? […]

JavaScript Roots: Core Language Essentials

(That’s a presentation embedded above. Use your left/right arrow keys to navigate through it. You might need to click it first in order to focus it.) Whilst we, JavaScript developers, are nowadays spoiled with tools, frameworks, build systems, etc. we might tend to forget some of the core things contained in the JavaScript language. Think […]