由于我的js类的性质,我有一个通用的参数拆分器。我不知道如何对这个函数进行apply或call,并传递arguments对象,而不是真正将其作为函数的参数传递。
function splitArgs(){
return {
text : arguments[0],
class : arguments[1] || ""
}
}
function doSomething(){
var args = splitArgs.call(this, arguments);
if(args.class)
// do stuff
}我试过了
splitArgs.call(this, arguments);
splitArgs.call(this, ...arguments);
splitArgs.apply(this, arguments);
splitArgs.apply(this, ...arguments);
splitArgs(...arguments);
https://stackoverflow.com/questions/38518112
复制相似问题