Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JavaScriptɾ³ýÊý×éÖÐÖ¸¶¨ÖµµÄÔªËØ

/* ·½·¨:Array.remove(dx)
* ¹¦ÄÜ:ɾ³ýÊý×éÔªËØ.
* ²ÎÊý:dxɾ³ýÔªËØµÄϱê.
* ·µ»Ø:ÔÚÔ­Êý×éÉÏÐÞ¸ÄÊý×é
*/
//¾­³£ÓõÄÊÇͨ¹ý±éÀú,ÖØ¹¹Êý×é.
Array.prototype.remove=function(dx)
{
if(isNaN(dx)||dx>this.length){return false;}
for(var i=0,n=0;i<this.length;i++)
{
if(this[i]!=this[dx])
{
this[n++]=this[i]
}
}
this.length-=1
}

//ÔÚÊý×éÖлñȡָ¶¨ÖµµÄÔªËØË÷Òý
Array.prototype.getIndexByValue= function(value)
{
var index = -1;
for (var i = 0; i < this.length; i++)
{
if (this[i] == value)
{
index = i;
break;
}
}
return index;
}
//ʹÓþÙÀý
a = ['1','2','3','4','5'];
var dx=a.getIndexByValue£¨"2");
a.remove(dx); //ɾ³ýϱêΪdxµÄÔªËØ 
¡¡ /*
¡¡ *¡¡·½·¨:Array.remove(dx)
¡¡ *¡¡¹¦ÄÜ:ɾ³ýÊý×éÔªËØ.
¡¡ *¡¡²ÎÊý:dxɾ³ýÔªËØµÄϱê.
¡¡ *¡¡·µ»Ø:ÔÚÔ­Êý×éÉÏÐÞ¸ÄÊý×é
¡¡ */
¡¡¡¡
¡¡//¾­³£ÓõÄÊÇͨ¹ý±éÀú,ÖØ¹¹Êý×é.
¡¡Array.prototype.remove=function(dx)
¡¡{
¡¡¡¡if(isNaN(dx)||dx>this.length){return false;}
¡¡¡¡for(var i=0,n=0;i<this.length;i++)
¡¡¡¡{
¡¡¡¡¡¡¡¡if(this[i]!=this[dx])
¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡this[n++]=this[i]
¡¡¡¡¡¡¡¡}
¡¡¡¡}
¡¡¡¡this.length-=1
¡¡}
¡¡a = ['1','2','3','4','5'];
¡¡alert("elements: "+a+"nLength: "+a.length);
¡¡a.remove(0); //ɾ³ýϱêΪ0µÄÔªËØ
¡¡alert("elements: "+a+"nLength: "+a.length);
¡¡¡¡
¡¡/*
¡¡ *¡¡·½·¨:Array.baoremove(dx)
¡¡ *¡¡¹¦ÄÜ:ɾ³ýÊý×éÔªËØ.
¡¡ *¡¡²ÎÊý:dxɾ³ýÔªËØµÄϱê.
¡¡ *¡¡·µ»Ø:ÔÚÔ­Êý×éÉÏÐÞ¸ÄÊý×é.
¡¡ */
¡¡¡¡
¡¡//ÎÒÃÇÒ²¿ÉÒÔÓÃspliceÀ´ÊµÏÖ.
¡¡¡¡
¡¡Array.prototype.baoremove = function(dx)
¡¡{
¡¡¡¡if(isNaN(dx)||dx>this.length){return false;}
¡¡¡¡this.splice(dx,1);
¡¡}
¡¡b = ['1','2','3','4','5'];
¡¡alert("elements: "+b+"nLength: "+b.length);
¡¡b.baoremove(1); //ɾ³ýϱêΪ1µÄÔªËØ
¡¡alert("elements: "+b+"nLength: "+b.length); 


Ïà¹ØÎĵµ£º

javascriptЧÂʾ­Ñé̸(Ò»)

±¾ÎÄÖ÷ÒªÊdzöÓÚÓÐÅóÓÑʹÓÃÎÒÔ­À´Ð´µÄautocompleteµÄJS¿Ø¼þ¡£µ±Êý¾ÝÁ¿´óµÄʱºò£¬»á³öÏÖЧÂʼ«ÆäÂýµÄÇé¿ö£¬ÎÒÔÚÕâ¶Îʱ¼ä×ö³öµÄһЩ²âÊÔÒ²¼°Ò»Ð©¾­Ñ飬Óë´ó¼Ò·ÖÏí£¬Èç¹ûÓдíµÄµØ·½£¬»¹ÇëÖ¸³ö¡£
¾­¹ý²âÊÔ£¬ÎÒÃǻᷢÏÖÈçϵÄÇé¿ö»òÕß˵µÄ½áÂÛ£¬Èç¹ûÄúµÄ²âÊÔ½á¹ûÓëÎҵIJ»·û£¬Çë˵Ã÷Ô­Òò£¬ÒÔ±ãÏ໥ѧϰ¡£
1£©µ±Ò»¸ö½Ï´óµÄHTML×Ö· ......

JavaScriptÊý¾ÝÀàÐÍ

JavaScript ÓÐÁùÖÖÊý¾ÝÀàÐÍ¡£Ö÷ÒªµÄÀàÐÍÓÐ number¡¢string¡¢object ÒÔ¼° Boolean ÀàÐÍ,ÆäËûÁ½ÖÖÀàÐÍΪ null ºÍ undefined¡£
¡¡¡¡ String ×Ö·û´®ÀàÐÍ:×Ö·û´®ÊÇÓõ¥ÒýºÅ»òË«ÒýºÅÀ´ËµÃ÷µÄ¡££¨Ê¹Óõ¥ÒýºÅÀ´ÊäÈë°üº¬ÒýºÅµÄ×Ö·û´®¡££©È磺“The cow jumped over the moon.”
ÊýÖµÊý¾ÝÀàÐÍ£ºJavaScript Ö§³ÖÕûÊýºÍ¸¡µã ......

[JavaScript] JavaScriptÖг£¼ûÒÉÎÊÕûÀí

JavaScriptÖеÄ"=="ºÍ"===" (ת)
Ê×ÏÈ£¬== equality µÈͬ£¬=== identity ºãµÈ£¨ÑϸñÏàµÈ£©¡£
==£¬ Á½±ßÖµÀàÐͲ»Í¬µÄʱºò£¬ÒªÏȽøÐÐÀàÐÍת»»£¬ÔٱȽϡ£
===£¬²»×öÀàÐÍת»»£¬ÀàÐͲ»Í¬µÄÒ»¶¨²»µÈ¡£
ÏÂÃæ·Ö±ð˵Ã÷£º
ÏÈ˵ ===£¬Õâ¸ö±È½Ï¼òµ¥¡£ÏÂÃæµÄ¹æÔòÓÃÀ´ÅжÏÁ½¸öÖµÊÇ·ñ===ÏàµÈ£º
1¡¢Èç¹ûÀàÐͲ»Í¬£¬¾Í[²»ÏàµÈ]
2 ......

[JavaScript] ¡¶¾«Í¨JavaScript¡·Ñ§Ï°£¨ËÄ£©~ÃæÏò¶ÔÏó

     
     prototype¾«²Ê×ÊÁÏ£º
     "javascriptÖ®prototype" http://www.cnblogs.com/zouhaijian/archive/2009/03/29/1424592.html(ºÜ¼òÔ¼µ«ÇåÎúµÄ½²ÊöÁËprototypeµÄÓÃ;)
     "JavaScript¶ÔÏóÄ£ÐÍ-Ö´ÐÐÄ£ÐÍ" http://w ......

¡¾Ô­´´¡¿JavaScript»ÃµÆÆ¬Ð¡ÊµÀý¼°½Ì³Ì£¨JsBox v1.2£©

ÐèÒªÔËÐл·¾³£º.net framework 3.0¼°ÒÔÉÏÔËÐл·¾³Ö§³Ö¡£
ÓÐϲ»¶µÄ¿´¿´°É£¬
ÄÚ¸½¾«ÐÄÖÆ×÷µÄJSЧ¹ûµÄ»ÃµÆÆ¬£¨Ö÷ҪʹÓÃjQuery¿â£©£¬ÒÔ¼°Æä°ïÖú£¬ÑÝʾ£¬´úÂë¿ÉÒÔÏÂÔØ£¬¹¤¾ßÃâ·ÑʹÓá£
ÏÂÔØµØÖ·£ºhttp://www.codeex.cn/blog/article.asp?id=62 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ