5 ms·
Can someone explain what's happening here? I'm a JavaScript dev, perfectly familiar with JS and with semi-colon insertion, but I'm not following the code after
by aerovistae 11y ago
Can someone explain what's happening here? I'm a JavaScript dev, perfectly familiar with JS and with semi-colon insertion, but I'm not following the code after "This is how V8 sees it:"
I don't see how or why the two lengthy statements using `apply` are being omitted entirely. I also don't see how that's "perfectly valid code" . . . I tried running it and got an error 'cannot read property forEach of undefined.'
- cornedor 11y agoHe probably left the function empty to keep it simple. And with "perfectly valid code" he's probably referring to not having any syntax error's, which is true.
- DanRosenwasser 11y agoI believe the issue is that the code gets parsed as a function expression that is being indexed by a series of strings in comma expressions. This happens instead of automatic semicolon insertion jumping in and then giving you the "expected" code. As a brief aside, TypeScript could help catch this sort of thing with its `--noImplicitAny` flag turned on.
- thiht 11y agoTo quote the article: "I’ve removed the internals for clarity" The content of the functions is just not relevant to the point he's trying to make
- aerovistae 11y agoOh. I read over that. Thanks.