当我看到一个与将PHP函数移植到JavaScript相关的问题时,我发现了我认为是错误的JavaScript代码:
function my_isnum(str, negative=false, decimal=false)
然后我在JSFiddle中尝试了这个:
function my_isnum(str, negative=false, decimal=-2)
{
console.log(arguments);
console.log(str);
console.log(negative);
console.log(decimal);
}
my_isnum("5", "Hi");
令我十分惊讶的是,在Firebug控制台中,我看到了以下内容:
["5", "Hi"]
5
Hi
-2
现在在Chrome中,我看到的是:
Uncaught SyntaxError: Unexpected token =
这个我不理解的是,这是 Firefox 支持的某个早期标准的例子吗(MDN 上关于
function
的内容似乎没有提到这个)?
let
表达式和解构赋值。 - the system