typeof检测到的数据类型有哪些?

来源:互联网 发布:淘宝店怎样设置客服 编辑:程序博客网 时间:2024/04/28 11:12
javascript共有6种数据类型:(基本类型5种)number、string、boolean、null、undefined  。(引用类型1种) object

typeof检测返回6种: undefined、boolean、string、number、object、function

注:null是一个只有一个值的特殊类型。表示一个空对象引用。用typeof检测返回是object。
typeof(undefined)  // undefined
typeof(null)  //  object
typeof(0)    //  number
typeof(false)  // boolean
typeof("")    // string
原创粉丝点击