var str = 'asdf' ;
var str1 = new String( 'asdf' );
typeof str; //"string"
typeof str1; //"object"
Object.prototype.toString.cal(str); //"[object String]"
Object.prototype.toString.call(str1); //"[object String]"
綜上所述,判斷是否爲字符串使用下邊的最保險
Object.prototype.toString.call(str) === "[object String]"
|