javascript - What is a constructor function's prototype? -
say, have constructor function called myclass
. , create object obj
out of it. obj
inherits myclass.prototype
. here question:
where
myclass.prototype
from? plain objectconstructor
property?
thanks answers.
// constructor function myclass() { } var obj = new myclass; // object inherits myclass.prototype obj.__proto__ == myclass.prototype; // => true // myclass.prototype inherits object.prototype myclass.prototype.__proto__ == object.prototype; // => true
where
myclass.prototype
from?
it's implicitly created when function object (myclass
) created.
is plain object
constructor
property?
yes, exactly. no more that, no magic involved :-)
Comments
Post a Comment