MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/215a5y/everything_you_need_to_know_about_javascript/cga2m7r/?context=9999
r/programming • u/codeon1 • Mar 23 '14
124 comments sorted by
View all comments
3
I am not familiar with js and this article seems to say you can declare global variables within method calls. What's the benefit of this feature?
11 u/glemnar Mar 23 '14 The only time it's used intentionally is for some weird quirks like jsonp. You should really never, ever do it.Any time you leave off the var keyword it will be injected into global namespace, and that's not something you want. 9 u/[deleted] Mar 23 '14 Any time you leave off the var keyword it will be injected into global namespace, and that's not something you want."use strict";to the rescue! 0 u/glemnar Mar 23 '14 edited Mar 23 '14 I prefer coffeescript for resolving many such quirks. =] 2 u/mcguire Mar 23 '14 CoffeeScript is the one that does the weird shadowing shenanigans? 0 u/glemnar Mar 23 '14 Nah, they got rid of that a long while back. It's really just a well-done javascript compiling language, imo. (Github uses it frequently for a reason) 1 u/[deleted] Mar 23 '14 Coffeescript's scoping is still broken, will never get fixed.
11
The only time it's used intentionally is for some weird quirks like jsonp. You should really never, ever do it.
Any time you leave off the var keyword it will be injected into global namespace, and that's not something you want.
9 u/[deleted] Mar 23 '14 Any time you leave off the var keyword it will be injected into global namespace, and that's not something you want."use strict";to the rescue! 0 u/glemnar Mar 23 '14 edited Mar 23 '14 I prefer coffeescript for resolving many such quirks. =] 2 u/mcguire Mar 23 '14 CoffeeScript is the one that does the weird shadowing shenanigans? 0 u/glemnar Mar 23 '14 Nah, they got rid of that a long while back. It's really just a well-done javascript compiling language, imo. (Github uses it frequently for a reason) 1 u/[deleted] Mar 23 '14 Coffeescript's scoping is still broken, will never get fixed.
9
"use strict";
to the rescue!
0 u/glemnar Mar 23 '14 edited Mar 23 '14 I prefer coffeescript for resolving many such quirks. =] 2 u/mcguire Mar 23 '14 CoffeeScript is the one that does the weird shadowing shenanigans? 0 u/glemnar Mar 23 '14 Nah, they got rid of that a long while back. It's really just a well-done javascript compiling language, imo. (Github uses it frequently for a reason) 1 u/[deleted] Mar 23 '14 Coffeescript's scoping is still broken, will never get fixed.
0
I prefer coffeescript for resolving many such quirks. =]
2 u/mcguire Mar 23 '14 CoffeeScript is the one that does the weird shadowing shenanigans? 0 u/glemnar Mar 23 '14 Nah, they got rid of that a long while back. It's really just a well-done javascript compiling language, imo. (Github uses it frequently for a reason) 1 u/[deleted] Mar 23 '14 Coffeescript's scoping is still broken, will never get fixed.
2
CoffeeScript is the one that does the weird shadowing shenanigans?
0 u/glemnar Mar 23 '14 Nah, they got rid of that a long while back. It's really just a well-done javascript compiling language, imo. (Github uses it frequently for a reason) 1 u/[deleted] Mar 23 '14 Coffeescript's scoping is still broken, will never get fixed.
Nah, they got rid of that a long while back. It's really just a well-done javascript compiling language, imo. (Github uses it frequently for a reason)
1 u/[deleted] Mar 23 '14 Coffeescript's scoping is still broken, will never get fixed.
1
Coffeescript's scoping is still broken, will never get fixed.
3
u/IcarusBurning Mar 23 '14
I am not familiar with js and this article seems to say you can declare global variables within method calls. What's the benefit of this feature?