javascript的push使用指南_基础知识

WBOY
Release: 2016-05-16 16:28:54
Original
1593 people have browsed it

push() 方法可向数组的末尾添加一个或多个元素,并返回新的长度。返回值为把指定的值添加到数组后的新长度。
语法:arrayObject.push(newelement1,newelement2,....,newelementX)
参数newelement1,必需。要添加到数组的第一个元素。
参数newelement2,可选。要添加到数组的第二个元素。
参数newelementX,可选。可添加多个元素。

push() 方法可把它的参数顺序添加到 arrayObject 的尾部。它直接修改 arrayObject,而不是创建一个新的数组。push() 方法和 pop() 方法使用数组提供的先进后出栈的功能。该方法会改变数组的长度。

示例:

复制代码代码如下:











Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!