我知道 Chrome 浏览器不支持扩展运算符。现在我有了这段代码:
var arr = [1, 2, 3];
var max = Math.max(...arr);
console.log('Max: '+ max);
上面的代码在 Chrome 中总是给我这个错误(但在 Mozilla 和 Safari 上有效):
Uncaught SyntaxError: Unexpected token ...
我在网上搜索了很多,但找不到任何对这种情况有用的答案。所以请帮助我找出我应该使用什么来代替 chrome 中的扩展运算符来完成在代码中执行的相同任务。
在此先感谢您的帮助。
最佳答案
尝试
Math.max.apply(Math, arr);
关于javascript - 在 Math.max(...arr) 中,我应该使用什么代替 Chrome 的扩展运算符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33003765/