dz̸JavaScriptµÄArray¶ÔÏó
Array×÷ΪJavaScriptµÄÒ»¸öÄÚÖöÔÏó£¬ÓÐ×ÅÇ¿´óµÄ¹¦ÄÜ£»Ïà¶ÔÓÚÆäËûÄÚÖöÔÏóÀ´Ëµ£¬ËûÓÐ×ÅÌØÊâµÄÓ÷¨£¬ÏÂÃæ¶Ô˵˵×Ô¼º¶ÔArrayµÄÓ÷¨µÄÒ»¸öС×ܽ᣺
1>ÓÃ;һ£ºÊý×é
Êý×é×î´ó´æ´¢Êý¾ÝΪËÄÊ®¶àÒÚ¸ö£¬Õâ¸ö¿Õ¼ä×ã¹»ÓÃÁË£¬ËùÒÔÊý×é¿ÉÒÔËæ±ãµÄÀ©ÈÝ¡£ÏÂÃæ¶Ô³£Óõķ½·¨½øÐÐ×ܽᣬÈçÏ£º
<!--´´½¨Êý×éµÄ·½Ê½-->
var array1 = new Array;
var array2 = new Array(2);
var array3 = new Array("green","red","blue");
var array4 = ["one","two","three"];
<!--¶ÔÊý×éµÄ²Ù×÷,ÌáʾËùÓвÙ×÷ÊǶÔÔarrayµÄ²Ù×÷-->
array3.length // 3
array3.toString() // green,red,blue
array3.valueOf() // green,red,blue
array3.join() // green,red,blue
array3.join("") // green red blue
array3.join("-") // green-red-blue
array3.shift() // red,blue
array3.unshift("black") // black,green,red,blue
<!--Êý×é×îÓÐ×Ô¶¯À©ÈݵŦÄÜ-->
array2.length // 2
array2[28] = "aa"; array2.length // 29
array2.shift(); array2.length //1
<!--×Ö·û´®ÓëÊý×é¼äµÄת»»-->
var str = "green"
var arr = str.split("");
arr.toString() // "g,r,e,e,n"
2>ÓÃ;¶þ£ºÕ»
Êý×éÔÚÓеÄʱºò»¹¿ÉÒÔµ±×÷Õ»À´Ê¹Ó㬴´½¨·½Ê½¸úÊý×éÀàËÆ£º
var arr = new Array;
arr.push("1");
arr.push("2");
arr.push("3");
arr.push("4");
for(var i=0;i<arr.length;i++){
alert(arr.pop());
}
//output: 4 3 2 1
Ïà¹ØÎĵµ£º
ºÜ¾Ã¾ÍÏë×ܽáһϹØÓÚjavascriptÐÔÄÜÓÅ»¯·½ÃæµÄһЩ¶«Î÷£¬Æ½Ê±Ò²ÓÐ×¢ÒâÊÕ¼¯Õâ·½ÃæµÄ×ÊÁÏ¡£°Ñdel.icio.usÀïµÄÊղصĶ«Î÷·³öÀ´¿´Ò»±é£¬²Å¾ªÆæµØ·¢ÏÖ£¬ÕâЩËùνµÄÓÅ»¯·½·¨´ó¶à³ö×Ô¡¶javascript¸ß¼¶³ÌÐòÉè¼Æ¡·Ò»Ê飬µ±È»Ò²Óиö±ð
²»Ò»ÑùµÄ¡£×ÜÖ®Õâ±¾ÊéÉϹØÓÚjavascriptÐÔÄÜÓÅ»¯µÄÄÚÈÝ×ã×ãÓÃÁ˽ü20Ò³À´½øÐвûÊö£¬ËùÒÔ½ñÌìÎÒÒ²Õ ......
1.Text µ¥Ðе¥ÁÐÊäÈëÔªËØ
¹¦ÄÜ£º¶ÔText±êʶÖеÄÔªËØʵʩÓÐЧµÄ¿ØÖÆ
»ù±¾ÊôÐÔ£º
Name£ºÉ趨Ìá½»ÐÅÏ ......
var docEle = function() {
return document.getElementById(arguments[0]) || false;
}
function cloDiv(){
var overlayID="overlay";
var msgID = "overlayMsg";
document.body.removeChild(docEle(overlayID));
document.body.removeChild(docEle(msgID));
}
function openNewDiv() {
......
1>zInherit£º
ËüÊÇÒ»¸ö×é¼þ£¬ÓÃÀ´¼Ì³Ð»ùÀàµÄËùÓÐÊôÐԺͷ½·¨¡£¸úÒÔǰ˵µ½µÄÔÐÍÁ´Ä£Ê½·Ç³£ÀàËÆ£¬Ö»²»¹ý±ÈÔÐ͸ü°²È«£¬Ò²ÎÞÐ뿼ÂDzÎÊýÎÊÌâ¡£ÏÂÃæ¿´¿´zInheritµÄÓ÷¨£º
¸Ã×é¼þÖÐÖ»ÓÐÁ½¸ö·½·¨£ºinheritfrom() instanceof()
func ......