我找到的最好的方法是检查字符串上的方法,即:if (x.substring) {// do string thing} else{// do other thing}或者如果您想对数字属性进行数字检查,if (x.toFixed) {// do number thing} else {// do other thing}这有点像“鸭子打字”,这取决于你哪种方式最有意义。我没有足够的业力来评论,但是对于盒装字符串和数字,typeof失败,即:alert(typeof new String('Hello World'));alert(typeof new Number(5));会警告“对象”。