ES6 Object.forOwn loop over object keys functionality

This question already has an answer here:

  • How do I loop through or enumerate a JavaScript object? 29 answers

  • ES2017引入了Object.entries()方法,该方法似乎是您要查找的内容:

    const obj = { a: 1, b: 2 };
    Object.entries(obj).forEach(([key, value]) => console.log(`key: ${key}, value: ${value}`));
    链接地址: http://www.djcxy.com/p/28840.html

    上一篇: 如何循环浏览JSON对象

    下一篇: ES6 Object.forOwn遍历对象键功能