javascript Js - 操纵数组

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Js - 操纵数组相关的知识,希望对你有一定的参考价值。

// .push takes one or more parameters and pushes them onto the end of the array.

var arr = [1,2,3];
arr.push(4);
//arr is now [1,2,3,4]

// .pop() is used to pop an value of the end of an array
var arr = [1,2,3];
arr.pop();
//arr is now [1,2]

// .shift is used to remove the first item from an array
var arr = [1,2,3];
arr.shift();
//arr is now [2,3]

// .unshift() adds an item at the beginning of the array
var arr = [1,2,3];
arr.unshift(0);
//arr is now [0,1,2,3]

以上是关于javascript Js - 操纵数组的主要内容,如果未能解决你的问题,请参考以下文章

Javascript更改/迁移/操纵HTML表格(Table)内容案例 (备选表格案例)

Javascript更改/迁移/操纵HTML表格(Table)内容案例 (备选表格案例)

JavaScript-14(操纵属性和window)

js函数式编程1-1

21JavaScript笔记

Javascript:操纵状态栏以显示日期?