typeof 与 js数据类型

    js的数据类型有null、undefied、string、number、boolean、object六个,然后我之前的【误区】: typeof的返回值和JS的数据类型是一样的。然而并不是 T.T

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/biangz/p/6497655.html