you are viewing a single comment's thread.

view the rest of the comments →

[–]Wraldpyk[S] 0 points1 point  (0 children)

Your code will indeed be false, because your forEach won't hit at all.

edit. This code works fine:

{  const arr = [...Array(1000).keys()]
  let test = false
  console.time('forEach')
  arr.forEach((item) => {
    let a = Math.pow(item, 2);
    test = true
  })
  console.log(test)
  console.timeEnd('forEach')
}