Extend a direct instance
Posted
by
Diolor
on Stack Overflow
See other posts from Stack Overflow
or by Diolor
Published on 2013-10-26T21:45:56Z
Indexed on
2013/10/26
21:54 UTC
Read the original article
Hit count: 297
JavaScript
|javascript-objects
We have a new instance of an object with four properties:
person={firstname:"John",lastname:"Doe",age:50,eyecolor:"blue"};
What is the best way to many other properties to that object? If we wanted few couple more sure we would:
person[address_no] = 4;
....
person[country] = 'Netherlands';
But what if we have a lot properties. Is there any minimalistic way like the one below? (I know it doesn't work)
person +={address_no: '4', .... , country: 'Netherlands'};
© Stack Overflow or respective owner