The closest I've seen is this, but it doesn't really help me since I need to bind some parameters for later use with setInterval。Javascript:參數解壓在function.prototype.bind()中?
更具體地:
[in] var d = function(l, m) {
console.log(l);
console.log(m);
}
[in] d.apply(window, [1,2])
[out] 1
[out] 2
[out-return-value] undefined
[in] d.bind(window, [1,2])()
[out] [1, 2]
[out] undefined
[out-return-value] undefined
如可以看到的,陣列是解壓與.apply()
,但不與.bind()
。有沒有辦法用.bind()
解開參數?
好像我之前回答了這樣一個問題:P –