初学 javascript,不知为何这个 object 的属性遍历总是失败?
<!DOCTYPE HTML>
<html>
<body>
<script>
function isNumeric(n)
{
return !isNaN(parseFloat(n)) && !isFinite(n);
}
function multiplyNumeric(obj)
{
for(var key in obj){
var tem = obj[key];
if(isNumeric(tem)){
obj[key] = tem * 2;
}
}
}
var menu = {
width : "200",
height : "400",
title : "My menu"
};
alert(menu.toSource());
multiplyNumeric(menu);
alert(menu.toSource());
</script>
</body>
</html>