forEach is not a function error with JavaScript array

前端 未结 11 567
梦毁少年i
梦毁少年i 2020-11-29 17:11

I\'m trying to make a simple loop:

const parent = this.el.parentElement
console.log(parent.children)
parent.children.forEach(child => {
  console.log(chil         


        
11条回答
  •  既然无缘
    2020-11-29 18:07

    Since you are using features of ES6 (arrow functions), you may also simply use a for loop like this:

    for(let child of [{0: [{'a':1,'b':2},{'c':3}]},{1:[]}]) {
      console.log(child)
    }

提交回复
热议问题