Extend existing JS array with Another Array Last Updated : 15 Nov, 2024 Comments Improve Suggest changes Like Article Like Report To extend an array with another without creating a new array we can use the JavaScript array.push() method. This method extend the array by adding the elements at the end. These are the following methods: 1. Using array.push() with Spread operator JavaScript array.push() method adds one or more elements to the end of an array and returns the new length of the array. Spread Operator expands an iterable into individual elements. JavaScript const a1 = [ 10, 20, 30 ] const a2 = [ 40, 50 ] // Extend the array using array.push() a1.push(...a2); console.log(a1); Output[ 10, 20, 30, 40, 50 ] 2. Using Array push.apply() MethodArray push.apply() method is used when the ES6 is not supported. It is used to add elements at the end of the array. JavaScript const a1 = [ 10, 20, 30 ] const a2 = [ 40, 50 ] // Extend the array using array.push.apply() a1.push.apply( a1, a2 ); console.log(a1); Output[ 10, 20, 30, 40, 50 ] 3. Using Spread OperatorThe spread operator is used to expand the individual elements from the array and these elements can be converter to array using the aray literals. JavaScript let a1 = [ 10, 20, 30 ] let a2 = [ 40, 50 ] a1 = [ ...a1, ...a2 ]; console.log(a1); OutputUpdated first array: [ 10, 20, 30, 40, 50 ] 4. Using array.splice() MethodThe array.splice() method is used to remove, replace and add one or more elements in the existing array. JavaScript let a1 = [ 10, 20, 30 ] let a2 = [ 40, 50 ] // Extend existing array using splice() a1.splice( a1.length, 0, ...a2); console.log(a1); Output[ 10, 20, 30, 40, 50 ] Comment More infoAdvertise with us Next Article Extend existing JS array with Another Array R ruturajsinhrathod3 Follow Improve Article Tags : JavaScript Web Technologies Similar Reads Copy Array Items Into Another Array in JavaScript In JavaScript, copying array items into another array in JavaScript is helpful when you want to make changes to the data without affecting the original array. It helps avoid mistakes, keeps the original data safe, and is useful when you need to work with a separate copy of the array for testing or p 5 min read JavaScript - Append Array At The End Of Another Array Here are the different approaches to append an array at the end of another array in JavaScriptpush() Method with Spread Operator - Most UsedIt uses push() combined with the spread operator to append elements of a2 to a1.JavaScriptlet a1 = [ 1, 2, 3 ]; let a2 = [ 4, 5, 6 ]; a1.push(...a2); console.lo 3 min read JavaScript - Append Array At The Beginning Of Another Array Here are the various approaches to append an array at the beginning of another array in JavaScriptUsing unshift() Method - Most CommonUses the unshift() method to add elements of a2 at the beginning of a1 using the spread operator.JavaScriptlet a1 = [ 4, 5, 6 ]; let a2 = [ 1, 2, 3 ]; a1.unshift(...a 2 min read How to Splice an Array Without Mutating the Original Array? To splice or remove elements without changing the original array, you can use various techniques to create a copy first. Here are the most effective ways to do this1. Using slice() and concat() Methods - Most UsedThe combination of slice() and concat() methods allows you to remove elements from an a 2 min read Interesting Facts about JavaScript Arrays Let us talk about some interesting facts about JavaScript Arrays that can make you an efficient programmer.Arrays are ObjectsJavaScript arrays are actually specialized objects, with indexed keys and special properties. They have a length property and are technically instances of the Array constructo 3 min read Like