If I have an object defined as:
var myObj={};
Then, I update this object with:
myObj['fruit']=['apple', 'orange'];
Later, I would like to append "[banana, melon]" to myObj['fruit']
, that's update myObj
to
['apple','orange','banana','melon']
what is the most elegant way to update 'fruit' attribute value of myObj in my case? That's update array by appending a new array.
--------EDIT-------
I need a way to append array as one variable, not extract each element of the appended array and push. e.g. oldArray
append with newArray = final array