var s1 = "perschon.com"; var s2 = "javascript"; var s3 = "tutorial"; var s = s1.concat(" ", s2, " ", s3); //s is now "perschon.com javascript tutorial"
Or, simplely use "
var s1 = "perschon.com"; var s2 = "javascript"; var s3 = "tutorial"; var s = s1 + " " + s2 + " " + s3; //same result
Or, use "
var s = "perschon.com"; var s2 = "javascript"; s += " " + s2; //s = "perschon.com javascript" var s3 = "tutorial"; s += " " +s3; //s="perschon.com javascript tutorial"
Another way to join an array of strings:
var arr = ["perschon","js", "string"]; var s = arr.join(" "); //s = "perschon js string"