简体   繁体   English

如何在JavaScript数组中增加价值?

[英]how to add value in array in javascript?

I want to compare a number with a collection of numbers. 我想将一个数字与一组数字进行比较。 So for it i want to know how we use use array in javascript and one thing more i want the syntax how to concatenate the values from a collection to this array. 因此,为此,我想知道我们如何在javascript中使用use数组,还有一件事,我想要语法如何将集合中的值连接到此数组。 Thanks in advance 提前致谢

array.push(value); //adding value to the end of the array
var newArray = array.concat(oldArray); //concat array with oldArray

Check this w3schools tutorial, it explains what you asked and more: 查看此w3schools教程,它说明了您的要求以及更多:

JavaScript Array Object JavaScript数组对象

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM