Answers for "how to get the key and value of an object using foreach in javascript"

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

Code answers related to "how to get the key and value of an object using foreach in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language