shift£ºÉ¾³ýÔÊý×éµÚÒ»Ï²¢·µ»Øɾ³ýÔªËصÄÖµ£»Èç¹ûÊý×éΪ¿ÕÔò·µ»Øundefined
var a = [1,2,3,4,5];
var b = a.shift(); //a£º[2,3,4,5] b£º1
unshift£º½«²ÎÊýÌí¼Óµ½ÔÊý×鿪ͷ£¬²¢·µ»ØÊý×éµÄ³¤¶È
var a = [1,2,3,4,5];
var b = a.unshift(-2,-1); //a£º[-2,-1,1,2,3,4,5] b£º7
×¢£ºÔÚIE6.0ϲâÊÔ·µ»ØÖµ×ÜΪundefined£¬FF2.0ϲâÊÔ·µ»ØֵΪ7£¬ËùÒÔÕâ¸ö·½·¨µÄ·µ»ØÖµ²»¿É¿¿£¬ÐèÒªÓ÷µ»Øֵʱ¿ÉÓÃsplice´úÌæ±¾·½·¨À´Ê¹Óá£
pop£ºÉ¾³ýÔÊý×é×îºóÒ»Ï²¢·µ»Øɾ³ýÔªËصÄÖµ£»Èç¹ûÊý×éΪ¿ÕÔò·µ»Øundefined
var a = [1,2,3,4,5];
var b = a.pop(); //a£º[1,2,3,4] b£º5
push£º½«²ÎÊýÌí¼Óµ½ÔÊý×éĩ⣬²¢·µ»ØÊý×éµÄ³¤¶È
var a = [1,2,3,4,5];
var b = a.push(6,7); //a£º[1,2,3,4,5,6,7] b£º7
concat£º·µ»ØÒ»¸öÐÂÊý×飬Êǽ«²ÎÊýÌí¼Óµ½ÔÊý×éÖй¹³ÉµÄ
var a = [1,2,3,4,5];
var b = a.concat(6,7); //a£º[1,2,3,4,5] b£º[1,2,3,4,5,6,7]
slice()ÔÀ´ÊÇÓÃÀ´½ØÈ¡Êý×éÖеÄÒ»²¿·Ö£¬ÕâÀïÎÒÓÃËüÀ´¸´ÖÆÊý×飬ËüµÄ¸ñʽÈçÏ£º
array.slice(start, end)
Èç¹ûÊ¡ÂÔÁËend²ÎÊý£¬ÔòÇзֵÄÊý×é°üº¬´Óstart¿ªÊ¼µ½Êý×é½áÊøµÄËùÓÐÔªËØ¡£
ÏÖÔÚÒªÓÃËüÀ´¸´ÖÆÊý×飬¾ÍÒ»ÐÐ:
var newArray=oldArray.slice(0);
splice(start,deleteCount,val1,val2,...)£º´ÓstartλÖÿªÊ¼É¾³ýdeleteCountÏ²¢´Ó¸ÃλÖÃÆð²åÈëval1,val2,...
var a = [1,2,3,4,5];
var b = a.splice(2,2,7,8,9); //a£º[1,2,7,8,9,5] b£º[3,4]
var b = a.splice(0,1); //ͬshift
a.splice(0,0,-2,-1); var b = a.length; //ͬunshift
var b = a.splice(a.length-1,1); //ͬpop
a.splice(a.length,0,6,7); var b = a.length; //ͬpush
reverse£º½«Êý×é·´Ðò
var a = [1,2,3,4,5];
var b = a.reverse(); //a£º[5,4,3,2,1] b£º[5,4,3,2,1]
sort(orderfunction)£º°´Ö¸¶¨µÄ²ÎÊý¶ÔÊý×é½øÐÐÅÅÐò
var a = [1,2,3,4,5];
var b = a.sort(); //a£º[1,2,3,4,5] b£º[1,2,3,4,5]
slice(start,end)£º·µ»Ø´ÓÔÊý×éÖÐÖ¸¶¨¿ªÊ¼Ï±굽½áÊøϱêÖ®¼äµÄÏî×é³ÉµÄÐÂÊý×é
var a = [1,2,3,4,5];
var b = a.slice(2,5); //a£º[1,2,3,4,5] b£º[3,4,5]
join(separator)£º½«Êý×éµÄÔªËØ×éÆðÒ»¸ö×Ö·û´®£¬ÒÔseparatorΪ·Ö¸ô·û£¬Ê¡ÂԵĻ°ÔòÓÃĬÈÏÓöººÅΪ·Ö¸ô·û
var a = [1,2,3,4,5];
var b = a.join("|"); //a£º[1,2,3,4,5] b£º"1|2|3|4|5"
javascript ÊÇÒ»ÖÖÇø·Ö´óСдµÄ³ÌÐòÓïÑÔ.
¶¨ÒåÊý×é:
var strweek= new Array(7);
Îʺűí´ïʽ
var i= (condition)?A:B;
Ï൱ÓÚif-else Óï¾ä;condition ³ÉÁ¢ Ö´ÐÐA £¬²»³ÉÁ¢Ö´ÐÐB;
switch Óï¾ä
var i=3;
var result="";
swithck(i);
{
case 1;
result="First";
case 2;
result="Second";
ca ......