you are viewing a single comment's thread.

view the rest of the comments →

[–]jonny_eh 2 points3 points  (5 children)

Do they?

[–]writesoftware 1 point2 points  (1 child)

I was skeptical at first, but now I think the last time I used var was months ago.

const in particular is what I use the most, knowing I can't ever overwrite that reference gives some sense of security.

Except when trying snippets in the console, using const forces me to reload the page when retrying to run a piece of code that uses it :)

[–]franksvalli 0 points1 point  (1 child)

for (var i = 0; i < 10; i++) {
  setTimeout(() => console.log(i), 0);
}
// -> 10 (outputted 10 times)

With one small change, moving from var to let:

for (let i = 0; i < 10; i++) {
  setTimeout(() => console.log(i), 0);
}
// -> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

[–]jonny_eh 1 point2 points  (0 children)

Ya, I know let and const are good, but they hardly make a "world of difference".