Thursday, November 20, 2014

Variables can be accessed by a javascript function

When a javascript function is called, sometime it is confusing on which variables it can access.
1. parameters passed by caller (decided at runtime)

2. local variables defined within the function,

3. closure variables
    closure variable only depends on where the function is defined, and it also includes different levels of parent scopes all the way up to the global scope.

4. global variables
   global variable is accessible in the sense of a special kind of closure variable, as all function will end up in the global scope.

5. this properties
   The properties of this object can be accessed by using this.property within a function. However, when the function is called, this object may be changed from time to time depending on how it is called. So be sure to check the property is valid before using it.

1 comment:

  1. Good blog. Keep sharing. I love them Are you also searching for Cheap assignments? we are the best solution for you. We are best known for delivering writing services to students without having to break the bank

    ReplyDelete