Concat-2

 

Example of JavaScript concat() function:

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <button onclick="joinArrays()">Concatinate arrays</button> <p id="sample"></p> <script> function joinArrays() { var countries = ["India", "Pakistan"]; var states = ["Punjab", "Haryana", "Himachal"]; var cities =["Chandigarh","Delhi","Peshawar"]; var result = countries.concat(states,cities); document.getElementById("sample").innerHTML = result; } </script> </body> </html>
Output