The usage of concat in JavaScript Array
In this issue, the editor will bring you about the use of concat in the JavaScript array. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
1. Concat () can create a new array based on all the items in the current array.
2. This method first creates a copy of the current array, then adds the received parameters to the end of the copy, and finally returns the newly built array.
Example
Var colors = ["red", "green", "blue"]; var colors2 = colors.concat ("yellow", ["black", "brown"]); alert (colors); / / red,green,bluealert (colors2); / / red,green,blue,yellow,black,brown var colors = ["red", "green", "blue", "yellow", "purple"]; var colors2 = colors.slice (1); var colors3 = colors.slice (1); alert (colors2) / / green,blue,yellow,purplealert (colors3); / / green,blue,yellow above is the use of concat in the JavaScript array shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.