|
|
|
|
|
by peferron
4182 days ago
|
|
Yes, "let" is better than "var". I could also have used a fat arrow in the forEach(). But my point was to list iteration variations, so outside of that I wrote traditional ES5. This illustrates the issue though. "var" is like "let" but without block scoping, so you should almost never use "var", but it's still there to trip newcomers. The fat arrow is like the "function" keyword and most of the time you can use them interchangeably, but if you rely on "this" they're not interchangeable anymore. This growing laundry list isn't exactly thrilling. I'm glad to have map(), filter(), every() and friends, though. |
|
In a language like JS you cannot have it all, but at least appreciate the improvements! ;)