Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding data to a JavaScript object literal

Tags:

javascript

This is my object literal:

var obj = {key1: value1};

How can I add

{key1: value1,value2,value3}

to obj?

like image 439
Randall444 Avatar asked Aug 21 '12 16:08

Randall444


1 Answers

The value of your object would have to be an array or object that stores the separate values, like so:

{key1: [value1,value2,value3]}

Or

{key1: new compositeValue(value1, value2, value3)}
like image 160
Nick Avatar answered Sep 29 '22 14:09

Nick