将数据添加到JavaScript对象文字

时间:2022-08-06 16:26:22

This is my object literal:

这是我的对象文字:

var obj = {key1: value1};

How can I add

我该如何添加

{key1: value1,value2,value3}

to obj?

1 个解决方案

#1


7  

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)}

#1


7  

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)}