1var str1 = "Hello ";
2var str2 = "world!";
3var res = str1.concat(str2);
4console.log(res);
1//This method adds two or more strings and returns a new single string.
2
3let str1 = new String( "This is string one" );
4let str2 = new String( "This is string two" );
5let str3 = str1.concat(str2.toString());
6console.log("str1 + str2 : "+str3)
7
8output:
9str1 + str2 : This is string oneThis is string two
1var arr = [1, 2, 3, 4];
2var arr2 = [5, 6, 7, 8];
3
4const both = arr.concat(arr2);
5
6console.log(both);
7//[1, 2, 3, 4, 5, 6, 7, 8]