`
liu208286
  • 浏览: 17103 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

JavaScript push()方法

阅读更多

定义:
使用push()方法可以向数组的末尾添加一个或多个元素并且返回新的长度 。

 

语法:

 

arrayObject.push(newelement1,newelement2,....,newelementX)

 

Parameter
参数Description
描述
newelement1Required. The first element to add to the array
必要选项。向数组添加的第一个元素
newelement2Optional. The second element to add to the array
可选项。向数组添加的第二个元素
newelementXOptional. Several elements may be added
可选项。可添加多个元素

 

注意:

 

要向数组的头部加入一个或多个元素,可以使用unshift()方法。

示例:

<script type="text/javascript">
var arr = new Array(3)
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"
document.write(arr + "<br />")
document.write(arr.push("Kai Jim") + "<br />")
document.write(arr)
</script>

 

 

文章转自:http://www.w3pop.com/learn/view/doc/jsref_push/

0
0
分享到:
评论
7 楼 beifangxiaocheng 2011-07-25  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
6 楼 beifangxiaocheng 2011-07-25  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
5 楼 beifangxiaocheng 2011-07-25  
                                                                                                                                                                                                                                                                                                                               
4 楼 beifangxiaocheng 2011-07-25  
                   
3 楼 beifangxiaocheng 2011-07-25  
                   
2 楼 beifangxiaocheng 2011-07-25  
手术室
1 楼 beifangxiaocheng 2011-07-25  
抄来的
" target="_blank">
抄来的
" />
抄来的
" target="_blank">
抄来的
" wmode="" quality="high" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="200" height="200">

相关推荐

    pushlet javascript push

    【标题】:“Pushlet JavaScript Push”技术解析 【描述】:在现代Web开发中,实时通信已经成为一个重要的需求,使得用户能够即时获取服务器上的新数据,而无需手动刷新页面。"Pushlet JavaScript Push"就是一种...

    javascript常用方法实例

    6. **数组方法**:JavaScript提供了许多处理数组的方法,如`push()`、`pop()`、`shift()`、`unshift()`、`splice()`、`slice()`等,用于添加、删除或修改数组元素。这些方法在处理网页数据时非常有用。 7. **字符串...

    JavaScript使用push方法添加一个元素到数组末尾用法实例

    在处理数组时,我们经常需要向数组的末尾添加新的元素,这时JavaScript的`push()`方法就派上了用场。`push()`方法是数组的一个内置方法,它用于在数组的末尾添加一个或多个元素,并返回数组的新长度。 在给定的实例...

    JavaScript模拟push_.docx

    在JavaScript中,`Array.prototype.push`是一个内置的方法,用于向数组的末尾添加一个或多个元素,并返回新的数组长度。在本文中,我们将探讨如何使用JavaScript模拟实现`push`方法,以及如何将其扩展为适用于所有...

    javaScript中push函数用法实例分析

    在JavaScript的Array.prototype.push方法内部实现中,我们可以通过以下代码了解其具体逻辑: ```javascript Array.prototype.push = function(){ var len = arguments.length; if(len &gt; 0) { for(var i = 0; i ;...

    JavaScript数组push方法使用注意事项

    本文主要介绍JavaScript数组中的push方法的使用注意事项,以及与之相关的其他数组方法的知识点。 首先,我们来详细解释push方法的使用和注意事项。push方法可以将一个或多个元素添加到数组的末尾,并返回添加元素后...

    浅谈JavaScript的push(),pop(),concat()方法_.docx

    JavaScript 数组方法详解 JavaScript 中的数组是一种复杂的...push()、pop() 和 concat() 方法是 JavaScript 中数组操作的三个基本方法,它们可以帮助开发者快速地操作和处理数组元素,从而提高开发效率和代码质量。

    javascript的push使用指南.doc

    javascript的push使用指南.doc

    Javascript数组中push方法用法分析

    JavaScript中的数组方法`push()`允许我们在数组末尾添加一个或多个元素,并返回更新后数组的长度。这个方法是数组原型链`Array.prototype.push`的一部分,因此任何具有数组行为的对象(如模拟数组的对象字面量)都...

    jquery中push()的用法(数组添加元素)

    push()方法的用法和普通的JavaScript数组的push()方法相同,都允许开发者向一个数组的末尾添加一个或多个元素,并且该方法会修改原数组,返回修改后数组的新长度。需要注意的是,jQuery的push()方法实际上是对...

    javascript的push使用指南

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

    关于JS数组追加数组采用push.apply的问题

     a.push.apply(a, b);以上的代码在mac的chrome下抛出了如下的异常 代码如下:Uncaught RangeError: Maximum call stack size exceeded如果把数组改为b = new Array(125623);小一个元素居然就好了,测试了一下其他...

    server push

    DWR(Direct Web Remoting)是一个开源的Java库,它简化了JavaScript和Java之间的交互,允许在Web应用中实现AJAX和Server Push功能。DWR使得开发者可以在浏览器端调用服务器端的Java方法,就像它们是本地函数一样,...

    Push.js-Javascript桌面通知库

    什么是push.js,A compact, cross-browser solution for Javascript desktop notifications 网页端即使消息推送插件.主要用于消息的即使提醒.

    JavaScript模拟push

    在JavaScript中,push方法是数组对象的一个常用方法,用于将一个或多个元素添加到数组的末尾,并返回新的数组长度。原生JavaScript数组的push方法是内置的,它可以直接在数组上调用以实现上述功能。然而,如果我们想...

    javascript使用数组的push方法完成快速排序

    在介绍的示例中,JavaScript使用数组的push方法来完成快速排序的具体实现步骤如下: 1. **递归终止条件**:如果数组长度小于等于1,则返回数组本身,因为长度为1的数组自然是有序的,不需要排序。 2. **取基准值**...

Global site tag (gtag.js) - Google Analytics