Read full article on the Infragistics blog
This is the second part of the series in 11 Things about JavaScript Functions that .NET Developers Should Know . In part 1 we discussed the following topics,
- JavaScript functions as an expression
- JavaScript functions as a statement
- Return statements in JavaScript functions
- Parameters in JavaScript functions
- The Arguments object in JavaScript functions
- Varargs JavaScript functions
In this part we will discuss the following topics,
- Scopes in functions
- Nested functions and Lexical scoping
- Functions’s this keyword
- Function as constructor
- The call() and the apply() methods
Scopes in function
Scoping stands for current context of code execution. Either a variable o expression can be executed in the context of the function they are created or in the global context of the JavaScript. JavaScript does not have the block scoping. It only supports scoping at the function level or global level.
Any variable defined anywhere in the function can be used everywhere in the function but not outside the function.
Leave a Reply