复习数组

1 split(' ') 切割符
把字符串分割为数组 引号间用空格

{{huan}}

//输出结果为:[ "hell", "vue" ]

2 join 拼接符

{{huan}}

//输出结果为:hell,vue

3 reverse 翻转

{{huan}}

//输出结果为:[ "vue", "hell" ]

4 *** string***
把对象的值转为字符串

        
        

5 concat 用于连接两个或多个数组

1,2,3,4,5
//输出结果为:1,2,3,4,5

6 slice
从已有的数组中返回选定的元素

Thomas,James
//输出结果为:Thomas,James

7 splice('坐标下添加 '‘删除0个或一个’)
从数组中添加/删除项目,然后返回被删除的项目

George,John,William,Thomas,James,Adrew,Martin
//输出结果为:George,John,William,Thomas,James,Adrew,Martin

8 ***push() ***
向数组的末尾添加一个或多个元素,并返回新的长度。

var arr = new Array(3)
arr[0] = "George"
arr[1] = "John"
arr[2] = "Thomas"
document.write(arr.push("James") )//输出结果为:4
document.write(arr)//输出结果为:George,John,Thomas,James

9 pop()
删除并返回数组的最后一个元素。

ThomasGeorge,John
//输出结果为:Thomas
//输出结果为:George,John

10 unshift
向数组的开头添加一个或更多元素,并返回新的长度


//输出结果为:
George,John,Thomas
George
John,Thomas

你可能感兴趣的:(复习数组)