欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript typeof的用法與typeof運算符介紹[詳細]第1/2頁

 更新時間:2008年10月31日 23:10:50   作者:  
下面是對于typeof運算符的詳細介紹跟typeof的一些用法,分析,學(xué)習(xí)typeof的朋友,看完了,這篇應(yīng)該能有所收獲。
經(jīng)常會在js里用到數(shù)組,比如 多個名字相同的input, 若是動態(tài)生成的, 提交時就需要判斷其是否是數(shù)組.
if(document.mylist.length != "undefined" ) {} 這個用法有誤.
正確的是 if( typeof(document.mylist.length) != "undefined" ) {}
或 if( !isNaN(document.mylist.length) ) {}
typeof的運算數(shù)未定義,返回的就是 "undefined".
運算數(shù)為數(shù)字 typeof(x) = "number"
字符串 typeof(x) = "string"
布爾值 typeof(x) = "boolean"
對象,數(shù)組和null typeof(x) = "object"
函數(shù) typeof(x) = "function"
typeof 運算符返回一個用來表示表達式的數(shù)據(jù)類型的字符串。
可能的字符串有:"number"、"string"、"boolean"、"object"、"function" 和 "undefined"。
如:
alert(typeof (123));//typeof(123)返回"number"
alert(typeof ("123"));//typeof("123")返回"string"
typeof 運算符
返回一個用來表示表達式的數(shù)據(jù)類型的字符串。
typeof[()expression[]] ;
expression 參數(shù)是需要查找類型信息的任意表達式。
說明
typeof 運算符把類型信息當(dāng)作字符串返回。typeof 返回值有六種可能: "number," "string," "boolean," "object," "function," 和 "undefined."
typeof 語法中的圓括號是可選項。

相關(guān)文章

最新評論