Working with Mongoose Arrays synchronously via async

This question already has an answer here:

  • Why is using “for…in” with array iteration a bad idea? 25 answers

  • iterating over an array using

    for(item in ['a', 'b']) {
      console.log(item)
    }
    

    will give you the array indexes: 0, 1

    You are looking for

    for(const item of ['a', 'b']) {
      console.log(item)
    }
    

    And that will print values: a, b

    Check this

    链接地址: http://www.djcxy.com/p/70032.html

    上一篇: 为什么在JavaScript中使用for循环时会发生这种情况?

    下一篇: 通过异步同步使用Mongoose Arrays