js typeof

typeof操作符返回一个字符串.

返回的字符串:"number," "string," "boolean," "object," "function," 和 "undefined."

typeof "" === 'string';

typeof NaN === 'number';

typeof undefined === 'undefined';

typeof new Date() === 'object';

typeof function(){} === 'function';

[obj].typeof('string');

多用于判断对象的类型。

也可用  [objFn] instanceOf Function 来判断对象。

 
原文地址:https://www.cnblogs.com/DennyZhao/p/8534115.html