0

我的代码

str = str.replace(/@@(.+)@@/g, function () {
    return myObj[arguments[1]];
});

为什么 jslint 在第 2 行给出错误“使用命名参数”?任何帮助,将不胜感激。

4

1 回答 1

2

Jslint 建议您不要使用参数伪数组,因为在某些浏览器中存在性能问题。

您可以在函数中指定命名参数,并使用这些:

str = str.replace(/@@(.+)@@/g, function(match, submatch) {
    return myObj[submatch];
});
于 2012-11-19T16:26:12.637 回答