4-1-JS数据类型及相关操作

js的数据类型

判断数据类型 用typeof
 
typeof "John"                 // alert(typeof "John") 返回 string 
typeof 3.14                   // 返回 number
typeof NaN                    // 返回 number
typeof false                  // 返回 boolean
typeof [1,2,3,4]              // 返回 object
typeof {name:'John', age:34}  // 返回 object
typeof new Date()             // 返回 object
typeof function () {}         // 返回 function
typeof myCar                  // 返回 undefined (if myCar is not declared)
typeof null                   // 返回 object

 

posted @ 2019-12-16 19:42  Cutelady  阅读(72)  评论(0编辑  收藏  举报