Array对象
(1)创建数组
(2)属性
* length 设置或返回数组中元素的数目
** //length属性
var arr1 = new Array(4,5,6);
document.write(arr1.length);
(3)方法
concat():连接数组 数组1.concat(数组2);
join():把数组根据指定字符进行分割
** var arr3 = [“mary”,“jack”,“lucy”];
document.write(arr3.join(“-”));
pop() 删除并返回数组的最后一个元素
push() 向数组的末尾添加元素,并返回新的长度
reverse() 颠倒数组中元素的顺序
Math对象
(1)进行数学运算,在Math对象里面的方法,直接使用Math.方法名称进行调用
(2)方法
ceil(x) 对一个数进行向上取整。
floor(x) 对一个数进向下取整。
round(x) 把一个数四舍五入为最接近的整数
random() 返回 0 ~ 1 之间的随机数
** 代码
var a = 10.2;
//ceil(x) 对一个数进行上舍入。
document.write(Math.ceil(a)); //11
document.write(“
”);
//floor(x) 对一个数进行下舍入。
document.write(Math.floor(a));
document.write(“
”);
//round(x) 把一个数四舍五入为最接近的整数
document.write(Math.round(a));
document.write(“
”);
//random() 返回 0 ~ 1 之间的随机数
document.write(Math.random());
//生成0-9之间的随机数 0.0 – 0.9之间的值
document.write(“
”);
document.write(Math.floor(Math.random()*10));
Date对象
(1)进行日期操作的对象
(2)使用Date对象,new Date();
(3)方法
toLocaleString() 根据本地时间格式,把 Date 对象转换为字符串。
得到当前的年 getFullYear() 从 Date 对象以四位数字返回年份
得到当前的月 getMonth() 从 Date 对象返回月份 (0 ~ 11)
得到当前的星期 getDay() 从 Date 对象返回一周中的某一天 (0 ~ 6)
** 如果当前的星期是星期日,返回的是0
** document.write(date.getDay())
得到当前的日 getDate() 从 Date 对象返回一个月中的某一天 (1 ~ 31)
得到当前的小时 getHours()
得到当前的分 getMinutes()
得到当前的秒 getSeconds()
得到毫秒数 getTime() 返回 1970 年 1 月 1 日至今的毫秒数
RegRxp对象
(1)RegExp 对象表示正则表达式
(2)正则表达式:规定字符串出现的规范
(3)使用:new RegExp(“正则表达式”)
(4)方法:
* test() 检索字符串中指定的值。如果存在匹配的字符返回 true,如果不存在匹配的字符返回 false。
(5)代码
//创建正则表达式对象
var reg = new RegExp(“[a]”);
//创建一个字符串
var name = “lisi”;
/