“continue” in cursor.forEach()

前端 未结 5 600
猫巷女王i
猫巷女王i 2020-12-12 14:04

I\'m building an app using meteor.js and MongoDB and I have a question about cursor.forEach(). I want to check some conditions in the beginning of each forEach iteration and

5条回答
  •  我在风中等你
    2020-12-12 14:44

    Making use of JavaScripts short-circuit evaluation. If el.shouldBeProcessed returns true, doSomeLengthyOperation

    elementsCollection.forEach( el => 
      el.shouldBeProcessed && doSomeLengthyOperation()
    );
    

提交回复
热议问题