JavaScript¾«´â¶ÁÊé±Ê¼Ç(8)
µÚ8ÕÂ
·½·¨
JavaScript
°üº¬ÁËÉÙÁ¿¿ÉÓÃ
ÔÚ±ê×¼ÀàÐÍÉϵıê×¼·½·¨¡£
Array
array.concat(item…)
concat
·½·¨·µ»ØÒ»¸öÐÂÊý×飬Ëü
°üº¬
array
µÄdz¸´ÖÆ
(shallow copy)
²¢½«
1
¸ö»ò¶à¸ö²ÎÊý
item
¸½¼ÓÔÚÆäºó¡£Èç¹û²ÎÊý
item
ÊÇÒ»¸öÊý×飬ÄÇôËüµÄÿ¸öÔªËػᱻ·Ö±ðÌí¼Ó¡£´ËÍ⣬Çë²Î¼û±¾ÕºóÃæµÄ
array.push(item…)
·½·¨¡£
var a=[‘a’,’b’,’c’];
var b=[‘x’,’y’,’z’];
var ca.concat(b,true);
//c
ÊÇ
[‘a’,’b’,’c’,
‘x’,’y’,’z’,true]
array.join(separator)
join
·½·¨°ÑÒ»¸ö
array
¹¹Ôì³ÉÒ»¸ö×Ö·û´®¡£Ëü½«
array
ÖеÄÿ¸öÔªËع¹Ôì³ÉÒ»¸ö×Ö·û´®£¬²¢ÓÃÒ»¸ö
separator
Ϊ·Ö¸ô·û°ÑËüÃÇÁ¬½ÓÔÚÒ»Æð¡£Ä¬ÈϵÄ
separator
ÊÇ
’,’
¡£ÎªÁËʵÏÖÎÞ¼ä¸ôµÄÁ¬½Ó£¬ÎÒÃÇ¿ÉÒÔʹÓÿÕ×Ö·û´®×÷Ϊ
separator
¡£
Èç¹ûÄãÏë°Ñ´óÁ¿µÄƬ¶Î×é×°³ÉÒ»¸ö
×Ö·û´®£¬°ÑÕâЩƬ¶Î·Åµ½Ò»¸öÊý×éÖв¢ÓÃ
join
·½·¨Á¬½ÓËüÃÇͨ³£±ÈÓÃ
+
ÔËËã·ûÁ¬½ÓÕâЩƬ¶ÎÒª¿ì¡£
var a=['a','b','c'];
a.push('d');
var c=a.join('');
//c
ÊÇ
'abcd'
array.pop()
pop
ºÍ
push
·½·¨Ê¹Êý×é
array
Ïñ¶ÑÕ»
(stack)
Ò»Ñù¹¤×÷¡£
pop
·½·¨ÒƳý
array
ÖеÄ×îºóÒ»¸öÔªËز¢·µ»Ø¸ÃÔªËØ¡£Èç¹û¸Ã
array
Êǿյģ¬Ëü»á·µ»Ø
undefined
¡£
var a=['a','b','c'];
var c=a.pop();
//a
ÊÇ
['a','b'],c
ÊÇ
'c'
array.push(item…)
push
·½·¨½«Ò»¸ö»ò¶à¸ö²ÎÊý
item
¸½¼Óµ½Ò»¸öÊý×éµÄβ²¿¡£²»Ïñ
concat
·½·¨ÄÇÑù£¬Ëü»áÐ޸ĸÃÊý×é
array
£¬Èç¹û²ÎÊý
item
ÊÇÒ»¸öÊý×飬Ëü»á½«²ÎÊýÊý×é×÷Ϊµ¥¸öÔªËØÕû¸öÌí¼Óµ½Êý×éÖС£Ëü·µ»ØÕâ¸öÊý×é
array
µÄ㤶ÈÖµ¡£
var
a=['a','b','c'];
var
b=['x','y','z'];
var
c=a.push(b,true);
array.reverse()
reverse
·½·¨·´×ª
array
ÖеÄÔªËصÄ˳Ðò¡£Ëü·µ»Øµ±Ç°µÄ
array
£º
var a=['a','b','c'];
var b=a.reverse();
//a
ºÍ
b
¶¼ÊÇ
['c','b','a']
array.shift()
shift
·½·¨ÒƳýÊý×é
array
ÖеĵÚÒ»¸öÔª
Ïà¹ØÎĵµ£º
ʼþÔ´¶ÔÏó
event.srcElement.tagName
event.srcElement.type
²¶»ñÊÍ·Å
event.srcElement.setCapture();
event.srcElement.releaseCapture();
ʼþ°´¼ü
event.keyCode
event.shiftKey
event.altKey
event.ctrlKey
ʼþ·µ»ØÖµ
event.returnValue
Êó±êλÖÃ
event.x
e ......
Õâ¿ÉÄÜÊÇ×î±»ºöÂÔµÄÎĵµ²Ù×÷Ö®Ò»£¬Õⶼ¹Ö΢ÈíµÄ²»×÷ΪÓëW3CµÄÎÞÄÜ£¬¸ãµ½´ó¼ÒÖ»ÖªµÀappendChildÓëinsertBefore¡£ºóÀ´±¬³öappendChildÔÚIEÓÐbug£¬ºÃÁË£¬ÒÔºóÖ»ÓÃinsertBeforeÁË¡£ÏÖÔÚjQueryÐËÆðºó£¬ÎÞÊý¸ÏѼ×ÓÉϼܵÄjavascriptËØÈËÁ¬»ù±¾APIÒ²²»Ñ§ÁË£¬Ö±½ÓÉÏÊÖappend£¬ preppend£¬ before£¬ afterÓëreplaceWith£¬Õâ±È½Ï±¯°§¡ ......
<script type="text/javascript">
function uniqueArr(arr)
{
arr = arr || [];
var a = {};
for (var i=0; i<arr.length; i++)
{
var v = arr[i];
&n ......
ÕâÖ÷ÒªÓÃÓÚÑ¡ÔñÆ÷¹ýÂËÖظ´ÔªËØʱÓõġ£
Éæ¼°ÈýÖÖ¿ÉÄܵÄÊֶΣºsourceIndex£¬uniqueIDÓë×Ô¶¨ÒåµÄuuid¡£
sourceIndex »ñÈ¡ÔªËؽڵãÔÚÒ³ÃæµÄ³öÏÖ˳Ðò£¬¼´ÎªÆäÔÚdocument.all¼¯ºÏÖеÄË÷ÒýºÅ¡£ÓÉÓÚҪ׼ȷ»ñÈ¡ÏȺóλÖã¬Èç¹ûÔÚÆäÇ°Ãæ²åÈëÒ»¸öÔªËؽڵ㣬ÄÇôËüµÄλÖþÍÒª¼ÓÒ»¡£»»ÑÔÖ®£¬ËüÊǶ¯Ì¬·ÖÅäµÄ£¬Ã¿´Î¶¼ÒªÖظ´¼ÆËã¡£×¢Ò⣬I ......
Èç¹ûÄãÏë¼ÓÎÒΪºÃÓÑ£ºÇëµã»÷ÒÔÏÂÁ´½Óhttp://hi.csdn.net/invite.php?u=8943&c=759c7fc189ea23c1
µÚ1ÕÂ
¾«»ª
JavaScript
µÄÌØÐÔÖÐÓÐÒ»²¿
·ÖÌØÐÔ´øÀ´µÄÂé·³Ô¶Ô¶³¬³öËüÃǵļÛÖµ¡£ÆäÖУ¬Ò»Ð©ÌØÐÔÊÇÒòΪ¹æ·¶ºÜ²»ÍêÉÆ£¬´Ó¶ø¿ÉÄܵ¼Ö¿ÉÒÆÖ²ÐÔµÄÎÊÌ⣻һЩÌØÐԻᵼÖÂÉú³ÉÄÑÒÔÀí½âºÍÐ޸ĵĴúÂ룻һЩÌØ
ÐÔ´ ......