The syntax of concat() method is as below :
str.concat(str2[, str3, str4, str5......strN])
It takes one or multiple parameters i.e. the strings to join with the origin string str. As explained above, a string is immutable. So, this method creates one new string joining all argument strings. The returned value is the newly created string. Remember that the returned string is a new string.
let str1 = "Hello"; let blank = " "; let str2 = "World"; let str3 = "!!"; let welcomeString = str1.concat(blank,str2,blank,str3); console.log(welcomeString);
It will print the below output :
Hello World !!
As you can see here, the strings are joined in the same order we are passing to the concat() method.