943

1、pop方法从数组中删除最后一个元素,并返回该元素的值。

vararray=["cat","dog","cow","chicken","mouse"]
varitem=array.pop()
console.log(array)//["cat","dog","cow","chicken"]
console.log(item)//mouse

2、push方法将一个或多个元素添加到数组的末尾,并返回该数组的新长度。

vararray=["football","basketball","badminton"]
vari=array.push("golfball")
console.log(array)//["football","basketball","badminton","golfball"]
console.log(i)//4

3、 reverse方法将数组中元素的位置颠倒,并返回该数组。

vararray=[1,2,3,4,5]
vararray2=array.reverse()
console.log(array)//[5,4,3,2,1]
console.log(array2===array)//true
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。