var str = "string";
var Fn = function() {var i;};
var f = new Fn();
document.write(str.__proto__+'<br />');//
document.write(str.prototype+'<br />');//undefined
document.write(str.constructor+'<br />');//function String() { [native code] }
document.write(str.__proto__.constructor+'<br />');//function String() { [native code] }
document.write(Fn.__proto__+'<br />');//function () { [native code] }
document.write(Fn.prototype+'<br />');//[object Object]
document.write(Fn.constructor+'<br />');//function Function() { [native code] }
document.write(Fn.__proto__.constructor+'<br />');//function Function() { [native code] }
document.write(Fn.__proto__.__proto__+'<br />');//[object Object]
document.write(f.__proto__+'<br />');//[object Object]
document.write(f.prototype+'<br />');//undefined
document.write(f.constructor+'<br />');//function () {var i;}
document.write(f.__proto__.constructor+'<br />');//function () {var i;}
document.write(f.__proto__.__proto__);//[object Object]
转自:
http://jsfox.cn/blog/javascript/understanding-javascript-prototype-chain.html
prototype和__proto__
最新推荐文章于 2024-07-05 19:23:38 发布