concat : JavaScript string addition

var my_var1=" Hello Welcome"
var my_var2=" to plus2net.com "
var my_var3= " JavaScript Section "
var my_var=my_var1.concat(my_var2, my_var3)
document.write(my_var);
The output of above code will be
Hello Welcome to plus2net.com JavaScript Section
We can add two or more strings by using concat string function in JavaScript.

Syntax of concat function.
variable.concat("string1","string2","string3","string4");

Examples

We can add three strings directly like this.
var new_var="";
new_var= new_var.concat("First one", " Second One", " Third one ");
document.write(new_var)

By using + operator

We can add strings by using + operation also like this
var my_var1=" Hello Welcome"
var my_var2=" to plus2net.com "
var my_var3= " JavaScript Section "
var my_var=my_var1 + my_var2 + my_var3
document.write(my_var);
Same result we can achieve by using single variable this way
var my_var=""
 my_var +=" Hello Welcome"
 my_var +=" to plus2net.com "
 my_var += " JavaScript Section "
document.write(my_var);

JavaScript String Reference Uppercase to lower case by toLowerCase() method
Subscribe to our YouTube Channel here



plus2net.com










We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer