日期:2014-05-16 浏览次数:20308 次
var base = { name : "kyfxbl" }; var obj = { __proto__ : base }; alert(obj.name);
obj.__proto__ == Object.prototype;// true Object.prototype.__proto__ == null;// true
function Base() { this.name = "kyfxbl"; } var obj = new Base(); alert(obj.__proto__ == Base.prototype);// true
function Base() { } alert(Base.__proto__ == Function.prototype);// true
alert(Function.prototype.constructor == Function);// true function func() { } alert(func.__proto__.constructor == Function);// true
function func1() { } function func2() { } func1.name = "kyfxbl"; func2.prototype.name = "kyfxbl"; var o1 = new func1(); var o2 = new func2(); alert(o1.name);// undefined alert(o2.name);// kyfxbl
function func() { } alert(func.prototype.constructor == func);// true alert(func.constructor == func);// false alert(func.constructor == Function);// true