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 数据的类型]

 

posted @ 2018-06-13 12:38  董威  阅读(2304)  评论(0编辑  收藏  举报