以下是30个JavaScript面试常考知识点总结,涵盖核心概念和常见问题:
变量类型与类型检测
undefined
、boolean
、number
、string
、symbol
、bigint
、null
Object
、Array
、Function
typeof
与 instanceof
的区别,Object.prototype.toString.call()
作用域与闭包
原型与继承
obj.__proto__
与 prototype
,new
的实现步骤。 this 指向
call/apply/bind
、new
绑定)。 this
。事件循环(Event Loop)
setTimeout
、setInterval
)与微任务(Promise.then
、MutationObserver
)的执行顺序。Promise
pending
/fulfilled
/rejected
),链式调用,Promise.all
/Promise.race
/Promise.allSettled
。Async/Await
async
返回 Promise,await
暂停执行直到异步完成。箭头函数
this
、arguments
,不能作为构造函数。解构赋值
扩展运算符与剩余参数
...
用于数组/对象展开,函数参数收集(替代 arguments
)。模块化
export
/import
与 CommonJS 的 require
/module.exports
区别。Class 与继承
class
语法糖,extends
和 super
实现继承。Symbol 与 BigInt
Symbol
创建唯一值,BigInt
表示大整数。可选链与空值合并
?.
避免访问 null/undefined
属性,??
替代 ||
处理默认值。高阶函数
map
、filter
、debounce
)。柯里化(Currying)
sum(a)(b)(c)
。深拷贝与浅拷贝
JSON.parse(JSON.stringify())
的局限性,递归实现深拷贝。对象属性描述符
Object.defineProperty
的 configurable
、enumerable
、writable
、value
。事件冒泡与捕获
e.stopPropagation()
。事件委托(代理)
跨域解决方案
postMessage
。防抖(Debounce)与节流(Throttle)
内存泄漏
严格模式('use strict')
this
默认 undefined
。Map 与 Set
Map
支持任意类型键,Set
自动去重。Proxy 与 Reflect
Proxy
拦截对象操作,Reflect
提供默认行为。Generator 函数
function*
定义,yield
暂停执行,next()
恢复。错误处理
try/catch
捕获同步错误,Promise.catch
处理异步错误。Web Workers
postMessage
通信。设计模式
Promise
、call/apply/bind
、防抖/节流、深拷贝、数组扁平化、柯里化等。掌握这些知识点能覆盖大部分JavaScript面试考点,建议结合代码实践加深理解。