Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to add new key value to json object in javascript

const data = [{ a: 1, b: 2 }, { b: 4, c: 5 }];
const data2 = {ASD:10};

for (let i = 0; i < data.length; i++) {
  data[i] = Object.assign(data[i], data2);
}

console.log(data);
Source by salesforce.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #add #key #json #object #javascript
ADD COMMENT
Topic
Name
1+3 =