javascript-tutorial / en.javascript.info

Modern JavaScript Tutorial
https://javascript.info
Other
23.25k stars 3.84k forks source link

Document error at structure #3713

Open bd1354 opened 1 month ago

bd1354 commented 1 month ago

https://javascript.info/structure at this page it says that; alert("Hello")

[1, 2].forEach(alert); if you remove semicolon at the first line of code that causes error but I got no error It worked without problem

joaquinelio commented 1 month ago

Can't be.

Maybe your environment hide the error? Does it show hello then 1 then 2 ?

It must get error as the engine should interpret as

alert("Hello")[1, 2].forEach(alert)