📜  使用 foreach 遍历 javascript - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:06.857000             🧑  作者: Mango

代码示例1
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]);
});