typeof()
用来获取一个变量或者表达式的类型,typeof返回如下几个结果:
number
boolean
string
function(函数)
object(NULL,数组,对象)
undefined
例如:
var a = 12;
console.log(typeof(a));
显示结果为 number
instanceof
常用来判断一个变量是否是某个对象的实例,返回结果是boolean值(true
/ false
)
例如:
function People(){
}
var student = new People();
console.log(student instanceof People);
返回结果为true