concat string with int javascript code example
Example 1: string concat javascript
let str1 = new String( "This is string one" );
let str2 = new String( "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
Example 2: concantene number in js
Use "" + 5 + 6 to force it to strings.
This works with numerical variables too:
var a = 5;
var b = 6;
console.log("" + a + b);
Example 3: string concat in js
let string1 = "Hello"
let string2 = "World"
let finalString = string1 + ", " + string2 + "!"