# Front-end interview knowledge points **Repository Path**: hlshare/front-end-interview-knowledge-points ## Basic Information - **Project Name**: Front-end interview knowledge points - **Description**: 前端面试知识点总结 - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-04-12 - **Last Updated**: 2021-04-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 前端面试知识点总结 ### 1、[数据类型](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Data_structures#%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B) 两大类:原始类型和对象类型 原始类型(6种):`Boolean、Number、String、Undefined、Symbol、Bigint、Null` 对象类型:`Object、Function` `Object`包含很多子类型:`Array、RegExp、Math、Map、Set、Date、JSON` 原始类型存储在栈上,对象类型存储在堆上,它的引用地址还是存在栈上。 ### 2、类型判断 #### typeof `typeof null` 的值为`object`,这是因为一个久远的bug,没有细究的必要,了解即可。如果想具体判断null类型的话直接`xxx === null`即可。 对于对象类型来说,`typeof `只能具体判断函数的类型为`function`,其他均为`object`。 #### instanceof `instanceof` 内部通过原型链的方式来判断是否为构造函数的实例、常用于判断具体的对象类型。 ```javascript [] instanceof Array ``` 另外我们还可以直接通过构造函数来判断类型 ```javascript [].constructor === Array ``` #### Object.prototype.toString 前几种方式或多或少存在一些缺陷,`Object.prototype.toString`综合来看是最佳选择,能判断的类型最完整。 ```javascript Object.prototype.toString.call(null) // "[object Null]" ``` #### isXXX API 例如:isNaN、isArray