typeof与js数据类型

    js有6种数据类型有null、undefied、string、number、boolean、object。

   然而我之前的【误区】: typeof的返回值和JS的数据类型是一样的。但是并不是(⊙o⊙)哦!

1. typeof方法返回值的是【字符串】:“string”、“number”、“function”、“object”、“boolean”、“undefined”。

2. typeof(null)、typeof({})、typeof([])、typeof(window)、typeof(document) 的返回值都是 “object”。

  typeof(NaN)、typeof(1) 返回值为 "number"

   备注:有疑问的话,可以测试一下!

原文地址:https://www.cnblogs.com/happybread/p/7398095.html