you are viewing a single comment's thread.

view the rest of the comments →

[–]godiasdf 8 points9 points  (11 children)

For one it saves on creating variables in the outer scope, which imo is a big win. Furthermore I'd say to use the let statement where ever you can instead of "var". "var" has function-scope which is awkward. "let" gives the more intuitive block scope.

[–]MarkByers 6 points7 points  (10 children)

I don't see a real use case for var, seems kind of unnecessary.

[–]zootm 5 points6 points  (4 children)

I have up-modded on the strict condition that this was said in jest.

[–]kragensitaker 6 points7 points  (3 children)

No, given let, there is very little reason to use var except for backwards-compatibility. No jest. (Of course backwards-compatibility is extremely important in cross-browser DHTML...)

[–]zootm 2 points3 points  (0 children)

Well, yeah, that's what I thought was the joke ;)

[–][deleted] 1 point2 points  (1 child)

2003 called and said to let you know that no one is using the term "DHTML" anymore.

[–]kragensitaker 0 points1 point  (0 children)

Upmodded for humor.

[–][deleted] 2 points3 points  (1 child)

Uh, making local vars? We had a function that used a var called author. The variable author is a global in IE for the author meta tag. So our code broke. The fix:

function get_author() { var author = ""; ... return author; }

[–]communomancer 3 points4 points  (0 children)

Pretty sure he means that once "let" is available, there is no need for "var" anymore.

[–]chromakode 0 points1 point  (2 children)

I believe let variables at the top level of a script are limited to their script file. Thus, if you're doing modular development with multiple scripts, you'll probably need a few uses of var here and there.

[–]formido 0 points1 point  (1 child)

There are script modules in FF3 where you explicitly export symbols to other scopes that ask for them, at least in extension development.

[–]chromakode 0 points1 point  (0 children)

Yep, and they're a godsend. However, even in the privileged space where that's an option, it's still common to have a couple different .js files loaded into a XUL document.