Const vs Var vs Let - JavaScript ES6

preview_player
Показать описание
Learn about the difference between const, var, and let in JavaScript ES6 (ECMAScript 6).

Code

Other resources on topic:

JS Nuggets: Brisk JavaScript training and tips
Рекомендации по теме
Комментарии
Автор

Nicely short and focused explained. Thx for that. :)
But what I don't understand is, why don't use var in general? It seems to have more advantages than let.

hansuswurstus
Автор

The const keyword is pretty cool. I wonder about the people that needed "let", though :-)

(how LONG are your functions that you need this???)

As ranted elsewhere, even the bad/redundant JS features are things people need to know, so they can read the other guy's code.

Seriously, though, if I have decomposing assignment, I'm more likely to put a block in an IIFE which returns one or more longer term values, than to use a block with "let". Also, tend to use .forEach or Ramda map/filter operations more than for(;;) loops lately, so the block scope is kind of moot.

Roboprogs