我在youdontknowjs.com的这一部分,不知何故,我对识别对象,原型,财产等感到困惑。
这是代码:
function Foo(who) {
this.me = who;
}
Foo.prototype.identify = function() {
return "I am "+this.me;
};
var a1 = new Foo("a1");
var a2 = new Foo("a2");
a2.speak = function() {
alert("Hello, "+this.identify()+'."');
};
a1.constructor === Foo;
a1.constructor === a2.constructor;
a1.__proto__ === Foo.prototype;
a1.__proto__ = a2.__proto__;
我如何在console.log中创建对象,原型,构造函数和属性?