typeof说明
typeof是js的一个函数,用法是查看变量的数据类型,返回值有六种"number", “string”, “boolean”, “object”, “function” , “undefined”。
举例
js中判断变量是否存在 if(typeof a!= "undefined"){}
typeof 123 === "number"
typeof (666) === "number"
typeof "" === "string"
typeof "abc" === "string"
typeof (true) === "boolean"
typeof false === "boolean"
typeof undefined === "undefined"
typeof abcdef === "undefined"
typeof {a:123} === "object"
typeof [1,2,3] === "object"
typeof new Date() === "object"
typeof class C {} === "function"
typeof function(){} === "function"
typeof Math.sin === "function"
typeof null === "object"