Sunday, May 12, 2013

The superpowers of constructors

2:37 AM Posted by jinto jose No comments

Invoking a function as a constructor is a powerful feature of JavaScript, because when a constructor is invoked, the following special actions take place:
  • A new empty object is created.
  • This object is passed to the constructor as the this parameter, and thus becomes the constructor’s function context.
  • In the absence of any explicit return value, the new object is returned as the constructor’s value.


Post a Comment