📜  javascript .foreach - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:21.943000             🧑  作者: Mango

代码示例4
const arraySparse = [1,3,,7]
let numCallbackRuns = 0

arraySparse.forEach((element) => {
  console.log(element)
  numCallbackRuns++
})

console.log("numCallbackRuns: ", numCallbackRuns)

// 1
// 3
// 7
// numCallbackRuns: 3
// comment: as you can see the missing value between 3 and 7 didn't invoke callback function.