首页 > 其他分享 >无涯教程-push()函数

无涯教程-push()函数

时间:2024-02-03 10:32:47浏览次数:25  
标签:10 教程 element1 无涯 numbers 数组 push new

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

push() - 语法

array.push(element1, ..., elementN);    
  • element1,...,elementN    -  要添加到数组末尾的元素。

push() - 返回值

返回新数组的长度。

push() - 示例

var numbers=new Array(1, 4, 9);
var length=numbers.push(10); 
console.log("new numbers is : " + numbers );  
length=numbers.push(20); 
console.log("new numbers is : " + numbers );    

运行上面代码输出

new numbers is : 1,4,9,10 
new numbers is : 1,4,9,10,20

参考链接

https://www.learnfk.com/es6/es6-array-method-push.html

标签:10,教程,element1,无涯,numbers,数组,push,new
From: https://blog.51cto.com/u_14033984/9568012

相关文章

  • 无涯教程-every()函数
    every()方法检测数值元素的每个元素是否都符合条件。every()-语法array.every(callback[,thisObject]);callback   - 测试每个元素的功能。thisObject  - 执行回调时用作此对象。every()-返回值如果此数组中的每个元素是否都符合条件,符合则返回true......
  • 无涯教程-concat()函数
    concat()方法连接两个或更多的数组,并返回结果。concat()-语法array.concat(value1,value2,...,valueN);valueN  - 要连接到输出数组的数组和/或值。concat()-返回值返回一个新数组。concat()-示例varalpha=["a","b","c"];varnumeric=[1,2,3];var......
  • 无涯教程-String.prototype.includes(searchString, position = 0)函数
    该方法确定字符串是否是给定字符串的子字符串。String.prototype.includes-语法str.includes(searchString[,position])searchString-要搜索的子字符串。position    -该字符串中开始搜索searchString的位置;默认为0。String.prototype.includes-返回值t......
  • Angular 17+ 高级教程 – Angular Configuration (angular.json)
    前言记入一些基本的配置。 SetupIPAddress、SSL、Self-signedCertificate如果你对IPAddress、SSL、Self-signedCertification不熟悉,请看这篇先 VsCode,VisualStudio2022,AngularandLiveServerRunningThroughHttpsandIPAddress在angular.json添加设......
  • 无涯教程-String.prototype.startsWith(searchString, position = 0)函数
    该方法确定字符串是否以指定的字符开头。String.prototype.startsWith-语法str.startsWith(searchString[,position])searchString  - 在此字符串开头要搜索的字符。position     - 该字符串中开始搜索searchString的位置;默认为0。String.prototype.s......
  • 【幻兽帕鲁教程】一键配置游戏参数
    幻兽帕鲁部署完成之后,如果您想要按照自己的喜好来对游戏世界进行DIY,打造个性化的服务器,那么就需要通过配置游戏参数来完成。最近一段时间,这一步可谓是让众多玩家头疼不已,如何找到配置文件?如何配置死亡不掉落?如何设置游戏房间密码?由于直接编辑配置文件的成本较高,且可能会各种各样......
  • 【Docker】从零开始:9.Docker命令:Push推送仓库(Docker Hub,阿里云)
    【Docker】从零开始:9.Docker命令:Push推送仓库(DockerHub,阿里云):https://blog.csdn.net/sinat_36528886/article/details/134575054?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-1-134575054-blog-132139578.235^v43^pc_blog_bo......
  • GCC使用具体教程以及例子
    编译第一个C程序#include<stdio.h>intmain(void){printf("helloworld!\n");return0;}使用gcc命令将hello.c编译成可执行程序a.out,并运行: 将源文件hello.c编译为一个指定名称的可执行文件:hello,可以通过gcc-o参数来完成GCC编译过程分析 以demo.c为......
  • GCC使用教程——GCC是什么?
    整理学习来自:https://www.xinbaoku.com/gcc/对于GCC的认知,很多读者还仅停留在“GCC是一个C语言编译器”的层面,是很片面的。从本节开始,我将带领大家系统学习GCC,本节先带领大家系统地了解一下GCC。谈到GCC,就不得不提GNU计划。GNU全称GNU'sNotUNIX,又被称为“革奴计划”,......
  • 无涯教程-toString()函数
    此方法返回表示指定对象的字符串。toString()-语法string.toString()toString()-返回值返回表示指定对象的字符串。toString()-示例varstr="Applesareround,andApplesareJuicy.";console.log(str.toString());运行上面代码输出Applesareround,an......