码迷,mamicode.com
首页 > 编程语言 > 详细

JavaScript学习笔记2-数组对象

时间:2015-07-06 23:07:03      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

 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>

 

JavaScript学习笔记2-数组对象

标签:

原文地址:http://www.cnblogs.com/Vito-L/p/4625571.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!