标签:
1 <!DOCTYPE html> 2 <html> 3 <head lang="en"> 4 <meta charset="UTF-8"> 5 <title></title> 6 </head> 7 <body> 8 <script> 9 //合并数组 10 var arr1 = ["Hello","World","PHP","Js"]; 11 var arr2 = ["name","age","sex","weight"]; 12 var arr3 = arr1.concat(arr2);//合并数组,arr1合并arr2 13 // document.write(arr3); 14 //数组排序 15 var na = [3,5,7,1,6,4,2]; 16 document.write(na.sort(function(a,b){ 17 return a-b;//升序 18 return b-a;//降序 19 })); 20 //追加 21 var yy = ["w","h"]; 22 yy.push("p");//追加字符p 23 document.write(yy); 24 //反转 25 var tt = ["o","l","l","e","h"]; 26 document.write(tt.reverse());//反转数组 27 </script> 28 </body> 29 </html>
标签:
原文地址:http://www.cnblogs.com/Vito-L/p/4625571.html