为什么添加原型后构造函数会从Foo变为Object?如何访问原始构造函数?
代码:
function Foo() {}
var foo1 = new Foo();
console.log('foo1: ' + foo1.constructor);
Foo.prototype = {}
var foo2 = new Foo();
console.log('foo2: ' + foo2.constructor);
输出:
foo1: function Foo() {}
foo2: function Object() {
[native code]
}