Bootstrap

前端面试每日一题----基础篇

1. javascript数据类型

基本数据类型:number、string、boolean、underfined、null、symbol(es6新增)

引用数据类型:array、function、object

数据类型检测:

​typeof

​1.对于基础数据类型,除了null都会显示正确类型

​2.对于引用数据类型,除了function都会显示object

   typeof 1 //number
   typeof 'hello' // string
   typeof true // boolean
   typeof underfined // underfined
   typeof Symbol() // symbol
   typeof NAN  // number
   typeof null // object

​instanceof : 判断A是否属于B的实例,即A的_proto_是否指向B的prototype
[] instanceof Array // true
({}) instanceof Object // true
[] instanceof Object // true 万物皆对象

​Object.prototype.toString.call(): 可以检测所有的类型~
Object.prototype.toString.call([]) // [Object Array]

;