js数据类型经典面试题

js的数据类型有:

原始数据类型:string  number  undefined  null  boolean

引用数据类型:Object  ***

检测这些数据类型的方法:

typeof检测,可以返回:string  number  undefined  boolean  object  function

typeof检测null  返回object

typeof检测[ ]   返回object

typeof检测number 返回object

它们都返回object,如何区分:

Object.prototype.toString.call(需要检测的数据);

返回:[Object 数据的类型]

 

猜你喜欢

转载自www.cnblogs.com/d-laowu/p/9171444.html