侯捷算法原理與實(shí)踐(選修)
instanceof
?是在原型鏈中查找是否是其實(shí)例(instance)
instanceof 實(shí)現(xiàn)
function _instanceof( instance, fn ){
? ?let i = instance.__proto__ ? ?while( i ){
? ? ? ?if( i === fn.prototype ){
? ? ? ? ? ?return true
? ? ? ?}
? ? ? ?i = i.__proto__ ? ?}
? ?return false}
繼承
實(shí)現(xiàn)繼承主要是要實(shí)現(xiàn)原型的屬性 + 方法
屬性繼承
call
標(biāo)簽: