我一直在尝试围绕 javascript 原型继承,在阅读 John Resig 的书“Pro Javascript Techniques”时,我正在尝试这样的事情:
alert("me".constructor); //Correctly return String
alert(alert.constructor); //Correctly return Function
然而,
alert(55.constructor);//I was expecting Number, but it returns error "SyntaxError: identifier starts immediately after numeric literal" in FF and in IE, it says it is expecting ")"
我还尝试了其他应该对数字起作用的函数,例如toFixed()
toPrecision()
,甚至toString()
但没有任何作用!
有人可以解释这种行为吗?