Bind
为document.querySelectorAll()起个别名
· ☕ 1 分钟

我将大量运行document.querySelectorAll(),并且想要一个速记别名。

var queryAll = document.querySelectorAll

queryAll('body')
TypeError: Illegal invocation

给document.querySelectorAll起一个queryAll的别名,调用时会报错。提示错误:非法调用。