I want to add multiple attributes to an existing object with existing attributes. Is there a more concise way than one line per new attribute?
myObject.name = 'don';
myObject.gender = 'male';
Everything on MDN shows how to do new objects with bracket notation, but not existing objects: https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Working_with_Objects
Sometimes I do it like this:
In ECMAscript 5 you can make us of defineProperties:
In ES6/ ES2015 you can use the Object.assign method
Use jQuery library
From How can I merge properties of two JavaScript objects dynamically?
EDIT
To be a bit clearer about how you could extend Object to use this function:
Usage:
Note: You certainly could implement a flexible merge conflict strategy depending on your needs.