Answers for "object properties foreach"

9

object foreach

const obj = {
  name: 'Jean-Luc Picard',
  rank: 'Captain'
};

// Prints "name Jean-Luc Picard" followed by "rank Captain"
Object.keys(obj).forEach(key => {
  console.log(key, obj[key]);
});
Posted by: Guest on October-27-2020
0

javascript set property for each object in array of objects

let yourArray = [{id:3},{id:2},{id:4}] 
 yourArray.forEach((item, index) => { 
 item.id = index 
})
Posted by: Guest on July-06-2020

Code answers related to "object properties foreach"

Code answers related to "Javascript"

Browse Popular Code Answers by Language