JavaScript Array methods : Array.concat() & Array.push()

Veröffentlicht am: 02 Februar 2020
auf dem Kanal: TechFun
7,426
6

Please check this article for more information
https://www.techwithfun.com/5-tricky-...

JavaScript Array Methods Array.concat() and Array.push()

Array.concat(): Immutable way of adding elements to an array, a new array will be created.
Array.push(): Mutable way of adding elements to an array. The original array will be changed.

You will learn array.concat and array.push methods in this tutorial.
You will also learn the difference between array push and array concat.

const arrayForConcat = [1,2,3];
const numberConcat = 4;
const newConcatArray = arrayForConcat.concat(numberConcat);

console.log("Array for Concat ::: ", arrayForConcat);
console.log("New Concat array ::: ", newConcatArray);

/* ################################## */

const arrayForPush = [1,2,3];
const numberPush = 4;
const lengthOfNewArray = arrayForPush.push(numberPush);

console.log("Array for Push ::: ", arrayForPush);
console.log("lengthOfNewArray ::: ", lengthOfNewArray);

#javascript #array #array.push #array.concat


Auf dieser Seite können Sie das Online-Video JavaScript Array methods : Array.concat() & Array.push() mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer TechFun 02 Februar 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 7,426 Mal angesehen und es wurde von 6 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!