关于javascript:js的apply-call-bind-arguments

3次阅读

共计 268 个字符,预计需要花费 1 分钟才能阅读完成。

1. 先来个链接帮忙了解根底概念:https://www.runoob.com/w3cnot…
2. 对于 arguments 是什么

通过 arguments 获取到全副参数(主动把函数里所有参数放在一个数组里)

const fun = () => {console.log(arguments)
}
fun(3, 5, 6, 8) // [3,5,6,8]

3.es6 的办法

通过 rest 形式

const fun = (first, two, ...remaining) => {console.log(first, two, remaining)
}
fun(3, 5, 6, 8) // 3 5 [6, 8]
正文完
 0