<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
function sum(){
var aaa = null;
for(var i=0;i<arguments.length;i++){
var hei = Number(arguments[i]);
/*if(isNaN(hei)){
continue;
}else{
aaa += hei;
}*/
isNaN(hei)?continue:aaa += hei;
}
return aaa
}
var bbb = sum(100,200,"300","xxxxx");
console.log(bbb);
</script>
</body>
</html>
把continue写在if里就能正常输出 . 写在三目里提示错误:arguments.html:22 Uncaught SyntaxError: Unexpected token continue . 为什么会出错?如何把if里的continue 写在三目里呢?
_Bling_
瑜伽兔子
相关分类