If I use an Array method directly on any Array after a line that’s missing a semicolon:
let foobar = 0
[0, 1, 2].some(foo => !!foo) // throws an error
it will throw an error: Uncaught TypeError: Cannot read properties of undefined (reading 'some')
Strangely, the error persists even after transcompiling the code with esbuild, or Babel.
It doesn’t happen if I add the missing semicolon, or use the Array method on a variable of Array type:
let foobar = 0;
[0, 1, 2].some(foo => !!foo) // works
let foobar = 0
const someArray = [0, 1, 2]
someArray.some(foo => !!foo) // also works
Why is that?