Skip to main content

Home/ ProgrammingPages/ Group items tagged computr_science

Rss Feed Group items tagged

Navneet Kumar

Javascript Closures - 0 views

  • If a value is assigned and the actual object does not have a property with the corresponding name a property of that name is created and the value is assigned to it. If it has the property then its value is re-set.
  • all objects may have prototypes, and prototypes are objects so they, in turn, may have prototypes, which may have prototypes, and so on forming what is called the prototype chain. The prototype chain ends when one of the objects in the chain has a null prototype. The default prototype for the Object constructor has a null prototype so
  • When a javascript function is called it enters an execution context, if another function is called (or the same function recursively) a new execution context is created and execution enters that context for the duration of the function call. Returning to the original execution context when that called function returns. Thus running javascript code forms a stack of execution contexts
  • ...5 more annotations...
  • First, in the execution context of a function, an "Activation" object is created.
  • The next step in the creation of the execution context for a function call is the creation of an arguments object, which is an array-like object with integer indexed members corresponding with the arguments passed to the function call, in order.
  • Next the execution context is assigned a scope. A scope consists of a list (or chain) of objects.
  • the Activation object is used as the Variable object (note this, it is important: they are the same object). Named properties of the Variable object are created for each of the function's formal parameters, and if arguments to the function call correspond with those parameters the values of those arguments are assigned to the properties (otherwise the assigned value is undefined)
  • It is the fact that the Activation object, with its arguments property, and the Variable object, with named properties corresponding with function local variables, are the same object, that allows the identifier arguments to be treated as if it was a function local variable.
  •  
    Detailed description of How javascript lanaguage handles resolution of property names, scopes of the functions, the importance prototype, and how closures are ultimately formed taking into consideration the above facts
1 - 1 of 1
Showing 20 items per page