javascript typeofµÄÓ÷¨
¾³£»áÔÚjsÀïÓõ½Êý×é,±ÈÈç ¶à¸öÃû×ÖÏàͬµÄinput, ÈôÊǶ¯Ì¬Éú³ÉµÄ, Ìύʱ¾ÍÐèÒªÅжÏÆäÊÇ·ñÊÇÊý×é.
if(document.mylist.length != "undefined" ) {} Õâ¸öÓ÷¨ÓÐÎó.
ÕýÈ·µÄÊÇ if( typeof(document.mylist.length) != "undefined" ) {}
»ò if( !isNaN(document.mylist.length) ) {}
typeofµÄÔËËãÊý䶨Òå,·µ»ØµÄ¾ÍÊÇ "undefined".
ÔËËãÊýΪÊý×Ö typeof(x) = "number"
×Ö·û´® typeof(x) = "string"
²¼¶ûÖµ typeof(x) = "boolean"
¶ÔÏó,Êý×éºÍnull typeof(x) = "object"
º¯Êý typeof(x) = "function"
typeof ÔËËã·û·µ»ØÒ»¸öÓÃÀ´±íʾ±í´ïʽµÄÊý¾ÝÀàÐ͵Ä×Ö·û´®¡£
¿ÉÄܵÄ×Ö·û´®ÓУº"number"¡¢"string"¡¢"boolean"¡¢"object"¡¢"function" ºÍ "undefined"¡£
È磺
alert(typeof (123));//typeof(123)·µ»Ø"number"
alert(typeof ("123"));//typeof("123")·µ»Ø"string"
typeof ÔËËã·û
·µ»ØÒ»¸öÓÃÀ´±íʾ±í´ïʽµÄÊý¾ÝÀàÐ͵Ä×Ö·û´®¡£
typeof
[(
)expression
[]
] ;
expression
²ÎÊýÊÇÐèÒª²éÕÒÀàÐÍÐÅÏ¢µÄÈÎÒâ±í´ïʽ
¡£
˵Ã÷
typeof
ÔËËã·û°ÑÀàÐÍÐÅÏ¢µ±×÷×Ö·û´®·µ»Ø¡£typeof
·µ»ØÖµÓÐÁùÖÖ¿ÉÄÜ£º "number," "string," "boolean," "object," "function," ºÍ "undefined."
typeof
Óï·¨ÖеÄÔ²À¨ºÅÊÇ¿ÉÑ¡Ïî¡£
À´×Ô£ºhttp://hi.baidu.com/fyears/blog/item/7494734eaff7720bb2de0516.html/cmtid/da4d8c77101ea810b051b9bc
Ïà¹ØÎĵµ£º
±¾ÎÄ×÷ÕßΪDavid
Mandelin£¬©¤©¤Mozilla JavaScriptÍŶӹ¤×÷ÈËÔ±¡£
Firefox 3.5ÓµÓÐÒ»¸öȫеÄJavaScriptÒýÇ棬½Ð×öTraceMonkey£¬ÔÚ¸ÃÒýÇæÉÏÅÜJSÓ¦ÓÃÒª±ÈFirefox
3¿ìµ½3-4±¶£¬´Ó¶øΪÏÖÓеÄÍøÂçÓ¦ÓüÓËÙ¡£ÕâƪÎÄÕ´óÖµÄÃèÊöÒ»ÏÂÔÚTraceMonkeyÖаüÀ¨µÄÖØÒª²¿¼þ£¬ÒÔ¼°ËûÃÇÊÇÈçºÎ¼ÓËÙJavaScriptµÄ¡£Í¬Ñù£¬ÔÚÁ˽âÕâÐ ......
<input type=text onkeypress="return event.keyCode>=48&&event.keyCode<=57||(this.value.indexOf('.')<0?event.keyCode==46:false)" onpaste="return !clipboardData.getData('text').match(/\D/)" ondragenter="return false">
<asp:TextBox ID="TextBox1" runat="server" onkeyu ......
1.¶ÔÓÚÊý×飬ÎÒÃÇ¿ÉÒÔ×Ô¼ºÐ´Ò»¸öindexOf()·½·¨:
[].indexOf || (Array.prototype.indexOf = function(v){
for(var i = this.length;i-- && this[i] !== v;);
return i; });
ʹÓ㺠var array = new Array();
array = ...;
if(array.ind ......
żµÃ±¾ÄÚÈÝ£¬¸Ð¾õдµÃºÜÊDz»´í£¬ÌØתÀ´Óë´ó¼Ò·ÖÏí
Èí¼þ˼Ï뾫ƷϵÁÐ
Îò͸ JavaScript
ÔÖø£ºÀîÕ½(leadzen)
http://www.cndev.org
http://www.cnblogs.com/leadzen
1
Òý×Ó
±à³ÌÊÀ½çÀïÖ»´æÔÚÁ½ÖÖ»ù±¾ÔªËØ£¬Ò»¸öÊÇÊý¾Ý£¬Ò»¸öÊÇ´úÂë¡£±à³ÌÊÀ½ç¾ÍÊÇÔÚÊý¾ÝºÍ´úÂëǧ˿ÍòÂƵľÀ²øÖгÊÏÖ³öÎÞÏÞµÄÉú»úºÍ»î
Á¦¡£
Êý¾ÝÌìÉú¾ÍÊ ......
JS²ã
// ¶¨ÒåÒ»¸öÈ«¾Ö
var xmlHttp;
// ·µ»ØÒ»¸öxmlHttpRequest¶ÔÏó
function createXMLHttpRequest() {
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
} else {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
......