4 ms·
No JS developer would do that. We all know that is global. Nowadays you use `const` or `let`. Any JS developer will have a linter that will tell them incase
by s_y_n_t_a_x 7y ago
No JS developer would do that.
We all know that is global.
Nowadays you use `const` or `let`.
Any JS developer will have a linter that will tell them incase they somehow made that mistake.
- tombert 7y agoEh, I actually like JS but I have definitely forgotten to add a "var" or "let" a few times, or sometimes I will do it correctly, get a bit overzealous with cutting, and accidentally remove the initial var declaration. I'm not saying that it breaks the language, but it definitely is irritating, especially if you're not using a linter.
- s_y_n_t_a_x 7y agoI come from Lua so I'm used to declaring local variables with "local". Also, I like knowing which variables won't be reassigned (const), and which will (let).
- shakna 7y agoWhilst I do find it irritating, I don't mind about the scope default so much, but I've certainly run into it (forgetting to specify) a lot. Mostly because JS is not the only language that I'll be working with at a time, and if I'm dancing between three or four and they have similar syntax, then mistakes creep in.
- jdminhbg 7y agoThat's all fine, but those are all workarounds for a design mistake in the language.
- s_y_n_t_a_x 7y agoNo it's a choice, apparently people can't have one.