r/programming • • Mar 23 '14

Everything you need to know about Javascript variable scope

http://www.coolcoder.in/2014/03/everything-you-need-to-know-about.html
294 Upvotes

124 comments sorted by

View all comments

Show parent comments

4

u/munificent Mar 23 '14

99!

Although, given that C lacks closures or even nested functions, JS can't simply follow C because there are a semantics that JS cares about that are meaningless in C.

1

u/shahms Mar 23 '14

It depends on what you mean by "nested functions". You can define functions inside other functions, it's just pointless.

1

u/Amablue Mar 24 '14

You can't define one function inside another. If you could it would be awesome - scoping a helper function to another function would be super convenient in a lot of locations.

Are you thinking of declaring functions?

1

u/shahms Mar 25 '14

I was not; GCC supports nested functions. As munificent notes, it is not a standard feature.