javascript concatenate string variable code example

Example 1: how to concatenate strings javascript

var str1 = "Hello ";
var str2 = "world!";
var res = str1.concat(str2);
// does not change the existing strings, but
// returns a new string containing the text
// of the joined strings.

Example 2: how to concatenate strings and variables in javascript

const helloName = name => `Hello ${name}!`

Example 3: 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 4: javascript string concatenation

var totn_string = '';

console.log(totn_string.concat('Tech','On','The','Net'));

//The following will be output to the web browser console log:

TechOnTheNet