instanceof 运算符
typeof 去判断一个变量的类型,是大家常用的,那么instanceof呢,看看的优势
var a =‘hellow word’
typeof(a) //string
a instanceof string //true 看不到优势
instanceof 在多层继承关系中的优势
function a(){}
function b(){}
a.prototype=new b()
var a1=new a()
a1 instanceof a //true
a1 instanceof b //true
浙公网安备 33010602011771号