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 来判断对象。

 

 

posted on 2018-03-09 15:20  zhaoqiang1980  阅读(115)  评论(0编辑  收藏  举报