javascript中的数据类型
var result = typeof(null); document.write("typeof null =" + result); // object document.write("</br>"); 上面result的结果是object
var sum = "1" + 2 + 3; document.write("'1' + 2 + 3 = " + sum); // 123 document.write("</br>"); var sum1 = "64" - 4; document.write("'64' - 4 = " + sum1); // 60 document.write("</br>"); var sum2 = NaN * 4; document.write("NaN * 4 = " + sum2); // NaN var result1 = void(0); document.write("</br>"); document.write("void(0) = " + result1); // undefined var result2 = null * 45; document.write("</br>"); document.write("null * 45 = " + result2); // 0 var result3 = 13 | 5; document.write("</br>"); document.write("13 | 5 = " + result3); // 13 var result4 = 13 & 5; document.write("</br>"); document.write("13 & 5 = " + result4); // 5 var result5 = 13 >> 2; document.write("</br>"); document.write("13 >> 2 = " + result5); // 3 var result6 = -13 >> 2; document.write("</br>"); document.write("-13 >> 2 = " + result6); // -4 var result7 = 13 << 2; document.write("</br>"); document.write("13 << 2 = " + result7); // 52 var result8 = -13 << 2; document.write("</br>"); document.write("-13 << 2 = " + result8); // -52 var str = "abdc.#dfe.%^%$"; str = str.toUpperCase(); document.write("</br>"); document.write("str.toUpperCase = " + str); // ABDC.#DFE.%^%$ var num1 = parseInt("28"); document.write("</br>"); document.write("parseInt('28') = " + num1); // 28 var num2 = parseInt("028"); document.write("</br>"); document.write("parseInt('028') = " + num2); // 2 (注意:8进制的数不能有8和9) var num3 = 11; var str1 = num3.toString(2); document.write("</br>"); document.write("十进制数11变为2进制 = " + str1); // 01111011 var str4 = "hello world!"; str4.replace(/world/,"my friend"); // hello world document.write("</br>"); document.write("str4 = " + str4);