首页 > Web开发 > 详细

js中typeof可以准确判断哪些变量类型

时间:2016-04-23 13:12:02      阅读:450      评论:0      收藏:0      [点我收藏+]

typeof 运算符返回一个用来表示表达式的数据类型的字符串。 
可能的字符串有:"number"、"string"、"boolean"、"object"、"function" 和 "undefined"。 

常用返回值说明

 

 

表达式 返回值
typeof undefined ‘undefined‘
typeof null ‘object‘
typeof true ‘boolean‘
typeof 123 ‘number‘
typeof "abc" ‘string‘
typeof function() {} ‘function‘
typeof {} ‘object‘
typeof [] ‘object‘
typeof unknownVariable ‘undefined‘

js中typeof可以准确判断哪些变量类型

原文:http://www.cnblogs.com/maqunjing/p/5424279.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!