一、Array数组对象
1、Array对象:使用单独的变量名来存储一系列的值。
2、数组的创建:例:var myArray=["Hello","yeleven","yeleven2"];
3、数组的访问:通过指定数组名以及索引号码,你可以访问某个特定的元素
4、数组常用方法:concat():合并数组
sort():排序
push():末尾追加元素
reverse():数组元素翻转
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<!DOCTYPE html>
<html>
<head>
<meta charset=
"UTF-8"
>
<title></title>
</head>
<body>
<script>
// var a = ["hello","world"];
// var b = ["yeleven","yeleven2"];
// var c = a.concat(b);
// document.write(c);
// var a = ["a","c","f","b","d","e"];
// document.write(a.sort());
// var a = ["a","c","f","b","d","e"];
// a.push("Z");
// document.write(a);
var
a = [
"c"
,
"b"
,
"a"
];
a.reverse();
document.write(a);
</script>
<div id=
"timetxt"
></div>
</body>
</html>
|
二、Math对象
1.Math对象:执行常见的算数任务
2.常用方法:round():四舍五入
random():返回0~1之间的随机数
max():返回最高值
min():返回最小值
abs():返回绝对值
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
<!DOCTYPE html>
<html>
<head>
<meta charset=
"UTF-8"
>
<title></title>
</head>
<body>
<script>
// document.write(Math.round(2.5));
// document.write(parseInt(Math.random()*10));
// document.write(Math.max(1,4,7,3,22,17,44));
// document.write(Math.min(1,2,5,3,9));
document.write(Math.abs(-10));
</script>
<div id=
"timetxt"
></div>
</body>
</html>
|
本文转自yeleven 51CTO博客,原文链接:http://blog.51cto.com/11317783/1793807