join two arrays javascript
let arr1 = [0, 1, 2];
let arr2 = [3, 5, 7];
let primes = arr1.concat(arr2);
// > [0, 1, 2, 3, 5, 7]//for ES5
var array1 = ["Rahul", "Sachin"];
var array2 = ["Sehwag", "Kohli"];
var output = array1.concat(array2);
console.log(output);
//for ES6, we use spread operators to concat arrays
var array1 = ["Dravid", "Tendulkar"];
var array2 = ["Virendra", "Virat"];
var output = [...array1, ...array2];
console.log(output);
var array1 = ["Vijendra", "Singh"];
var array2 = ["Singh", "Shakya"];
console.log(array1.concat(array2));//ES6
const array3 = [...array1, ...array2];// using push and apply to return the same array
const arr1 = ['a', 'b'];
const arr2 = ['c', 'd'];
arr1.push.apply(arr1, arr2);
console.log(arr1) // ['a', 'b', 'c', 'd']
Also in JavaScript:
- javascript replace all spaces
- jquery count selected options
- c# print object to json
- js index sorted
- post json in flutter
- js array to object with keys
- js immutable update object
- javascript picture delete after time
- node js catch any errors
- jquery AND operation
- regex for lowercase letters js
- Beautifule JS Console Log
- react native activityindicator
- number to array javascript
- in angular how to get router url without query params
- jquery get the parent node
- function to create an element javascript
- deep clone array in javascript
- javascript array reorder elements
- double click on element using javascript
- how to define variable in javascript
- angular on back skip routes
- javascript 2 decimal float array elements
- save object in localstorage shows [object Object]