/* *------------------------------------------------------------------------------- * [email protected] 2017-8-29 19:03 *------------------------------------------------------------------------------- * 1. prototype, constructor都是属性; * 2. 不同点:prototype是构造函数属性,是对象; * constructor是new出来的实例属性,是函数; * 3. constructor指向构造函数(构造器); * 4. constructor也是构造函数的属性(prototype)之属性; * 5. 实例的__proto__指向构造函数原型; */ function Fn() {}; var f = new Fn(); console.log(Fn.prototype.constructor === Fn); //true console.log(f.__proto__ === Fn.prototype); //true console.log(f.__proto__.constructor === Fn); //true console.log(f.constructor === Fn); //true
时间: 2024-09-29 10:16:56