I am fetching some json, but i want to add a key value pair to each object inside the array.
What i want is to add a key value pair to each object inside students array
You can do something like this:
var students = [ { city: 'California', company: 'ABC'}, { city: 'LA', company: 'PQR'}, { city: 'Mumbai', company: 'XYZ'}]; students.forEach((obj) => { obj['email']= '[email protected]'; console.log(obj); }); // Final Output console.log(students);
1.4m articles
1.4m replys
5 comments
57.0k users