forEach is not a function error with JavaScript array

前端 未结 11 583
梦毁少年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条回答
  •  旧时难觅i
    2020-11-29 18:03

    There is no need for the forEach, you can iterate using only the from's second parameter, like so:

    let nodeList = [{0: [{'a':1,'b':2},{'c':3}]},{1:[]}]
    Array.from(nodeList, child => {
      console.log(child)
    });

提交回复
热议问题