According to the docs, the latest node (Node 5+) should support the spread operator by default, like so:
const newObj = {
...oldObj,
newPrope
That's works in Node.js 8.5.0.
Example:
var oldObj = {
oldProperty: 0
}
var newObj = {
...oldObj,
newProperty: 1
}
console.log('Old Object: ' + JSON.stringify(oldObj, null, ' '))
console.log('New Object: ' + JSON.stringify(newObj, null, ' '))
Output:
Old Object: {
"oldProperty": 0
}
New Object: {
"oldProperty": 0,
"newProperty": 1
}
Screenshot from IDE Debug Console: