What is concat array in javascript?

 concat method array javascript:

concat() method merged one or more array elements and create a new array. Not found any effect in the original array.

 

Concat example in javascript:

 

const array1 = ["Red", "Green", "blue"];

const array2 = ["Black", "Orange"];

const array3 = ["White", "Coffee"];

const colors = array1.concat(array2);

console.log(colors);

// Array ["Red", "Green", "blue", "Black", "Orange"]

 

const moreColors = array1.concat(array2, array3);

console.log(moreColors);

// Array ["Red", "Green", "blue", "Black", "Orange", "White", "Coffee"]




No comments:

Note: Only a member of this blog may post a comment.

Copyright Reserved to Anything Learn. Powered by Blogger.