JavaScript(JS) string method - concat

The concat() method in JavaScript is used to concatenate one or more strings together, and it returns a new string.

Here is the syntax for the concat() method:

str.concat(string1, string2, ..., stringN)
S‮www:ecruo‬.theitroad.com

Here, str is the original string to which you want to concatenate the other strings, and string1 through stringN are the strings that you want to concatenate.

You can also use the concat() method with variables instead of strings. Here's an example:

let firstName = "John";
let lastName = "Doe";
let fullName = firstName.concat(" ", lastName);

In this example, the concat() method is used to concatenate the firstName and lastName variables together with a space between them, and the result is assigned to the fullName variable.

Note that the concat() method does not modify the original string. Instead, it returns a new string that is the concatenation of the original string and the other strings that were passed as arguments.