Thursday, August 30, 2018

JS: prototype

Object.prototype.say(){//some code}
thì tất cả các đối tượng trong trang web đều có thêm phương thức say

vd :
a = new Object();
a.say();//đã được định nghĩa

--CHú ý:
( new Foo ).__proto__ === Foo.prototype;
( new Foo ).prototype === undefined;
prototype is not available on the instances themselves (or other objects), but only on the constructor functions.

No comments:

Post a Comment