Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var arr = [{"a": "one", "b": "two", "c": "three"}];
- // Frist, convert this array by JSON.parse()
- var arr2 = JSON.parse(arr);
- var values = [];
- // Here are two methods to push values in javascript object
- // One...
- Object.assign(arr2, {d: "four", e: "five"});
- // Two
- /*arr2.d = "four";
- arr2.e = "five";*/
- values.push(arr2);
- // The resultant array will be like this...
- [{"a": "one", "b": "two", "c": "three", "d": "four", "e": "five"}]
- // If there are multiple objects in basic array, then you can use WHILE or FOR loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement