Answers for "for each of object"

4

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

for each of object

Object.keys(object).map(function(objectKey, index) {
    var value = object[objectKey];
    console.log(value);
});
Posted by: Guest on October-29-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language