I have an object var obj = {key1: "value1", key2: "value2"};
I want to add multiple values or array of values to key1 or key2 e.g
var obj = {key1: "arrayOfValues", key2: "value2"};
is it possible? basically I want to send it to php for process.
标签:
javascript
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
You can make objects in two ways.
Also you can be define values in array with/without initial size. For scenario one you can do the following in worst case scenario:
If you want to repeat the above codes in bracket notation, it will be like this
With bracket notation, you can use characters e.g 1,3,%, etc. that can't be used with dot notation.
You can just define an array for the property:
Or, assign it after the fact: