使用typeof算法
typeof的運(yùn)算數(shù)未定義,返回的就是 "undefined".
下面定義x為運(yùn)算數(shù):
有一下5種情況;
運(yùn)算數(shù)為數(shù)字 typeof(x) 返回的就是 "number";
字符串 typeof(x) 返回的就是 "string";
布爾值 typeof(x) 返回的就是 "boolean";
對(duì)象、數(shù)組 、null 時(shí): typeof(x) 返回的就是 "object";
函數(shù) typeof(x) 返回的就是 "function"。
例如:
var x=123456;
alert( typeof(x));//彈出“number”。
</script>
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注