Javascript examples for String:concat
The concat() method is used to join two or more strings.
Parameter | Description |
---|---|
string1, string2, ..., stringX | Required. The strings to be joined |
A new String, containing the text of the combined strings
The following code shows how to Join two strings:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w . j a va2 s.c om var str1 = "Hello "; var str2 = "world!"; var str3 = " Have a nice day!"; var res = str1.concat(str2, str3); document.getElementById("demo").innerHTML = res; } </script> </body> </html>