js 类型判断

1- typeof 只能判断基本数据类型,例如 console.log(typeof xx);

2- instanceof 判断对象的具体类型,例如 console.log(xx instance of  写的类型),如果数据是这个类型,结果为true,否则为false

3- constructor.name 获取对象的具体类型,例如 console.log(xx.constructor.name); 直接返回这个数据的类型

你可能感兴趣的:(js 类型判断)