//This method adds two or more strings and returns a new single string.let str1 =newString("This is string one");let str2 =newString("This is string two");let str3 = str1.concat(str2.toString());console.log("str1 + str2 : "+str3)output:
str1 + str2 :This is string oneThis is string two
// the fastest way to string concat in cycle when number of string is less than 1e6// see https://medium.com/@devchache/the-performance-of-javascript-string-concat-e52466ca2b3a// see https://www.javaer101.com/en/article/2631962.htmlfunctionconcat(arr){let str ='';for(let i =0; i < arr.length; i++){
str += arr[i];}return str;}
//ES6 spread operator same as arr1.concat(arr2)var arr1 =['1','2','3']var arr2 =[4,5,6]
arr1 =[...arr1, arr2]//... removes the [ and ] // leavin only an instance of inside.output:['1','2','3',4,5,6]