1、typeof 用来检测数据类型的运算符返回的都是字符串其次字符串中包含了对应的数据类型

number
string
boolenan
undefined
function
Object
typeof typeof typeof function(){}->返回结果string 

局限性

2、instaceof 检测某一个实例是否属于一个类

局限性

(1 instaceof Number) //false
(true instaceof Boolean) //false
(new Number(1) instaceof Number) //true

1、字面量创建出来的结果和实例创建出来的结果是有一定区别的只有实例创建出来的对象才是标准的对象

2、实例

var arr = [];
(arr instaceof Array)//true
(arr instaceof Object)//true
(fn instaceof Function) //true
(fn instaceof Object) // true

3、constructor 构造函数

    var arr = [];
    console.log(arr.constructor===Array);

4、Object.prototype.toString.call();

console.log(typeof 12); 

function dd (callbak){

    callbak && callbak();

}

var obj = [12,32];

console.log(obj instanceof Array);
console.log(Object.prototype.toString.call([]));
 console.log(Object.prototype.toString.call({}));
console.log(Object.prototype.toString.call(1));
console.log(Object.prototype.toString.call("sff"));
console.log(Object.prototype.toString.call(new Date));
console.log(Object.prototype.toString.call(/\d/));
console.log(Object.prototype.toString.call(null));
console.log(Object.prototype.toString.call(undefined));

跑码
101 声望8 粉丝

一万年太久,只争朝夕!