2016年8月17日 星期三

ndoejs, function, object


  • Properties of an object are looked up from two places:
    1. the object itself (Obj.foo), and
    2. if the property does not exist, on the prototype of the object (Obj.prototype.foo).

  • New objects are created using a constructor, which is a regular function invoked using new

  • The new constructor call (e.g. new Foo()):
    1. creates a new object,
    2. sets the prototype of that object to Foo.prototype and
    3. passes that as this to the constructor.


沒有留言:

張貼留言