loop through nested object properties

This question already has an answer here:

  • Loop through an array in JavaScript 35 answers

  • 好吧,我认为它会做你想要的。

    function iterObj(obj) {
    
      for (var key in obj) {
        console.log(key + ': ' + obj[key]);
        if (obj[key] !== null && typeof obj[key] === "object") {
          // Recurse into children
          iterObj(obj[key]);
        }
      }
    }
    
    链接地址: http://www.djcxy.com/p/24528.html

    上一篇: 如何引用字符串数组中的字符串?

    下一篇: 通过嵌套的对象属性进行循环