JS 原型与原型链
- 每个对象都有
__proto__
属性,但只有函数对象才有prototype
属性 - 所有对象的
__proto__
都指向其构造器的prototype
- 所有函数对象的
__proto__
都指向Function.prototype
- 原型对象(
Person.prototype
)是 构造函数(Person)的一个实例。(Person.prototype.constructor == Person
,person.constructor == Person
) person.__proto__ === Person.prototype
-
Person.prototype
是一个普通对象(即:Person.prototype.__proto__ === Object.prototype
) Person.__proto__ === Function.prototype
Object.prototype.__proto__ === null
-
Function.prototype
是唯一一个typeof XXX.prototype为 “function”的prototype
详情请看:https://www.jianshu.com/p/dee9f8b14771
JS变量提升:
https://www.jianshu.com/p/b87d620185f2
JS闭包:
https://www.jianshu.com/p/08fd069f35fc