Skip to content

Instantly share code, notes, and snippets.

@xxl007
xxl007 / 1.1.concatenating_two_or_more_strings.js
Last active August 29, 2015 14:00
Concatenating two or more strings
// Using the (+) operator (overloading)
var string1 = "This is a ";
var string2 = "test"
var string3= string1 + string2; // creates a new string with "This is a test"
// alternative using the shorthand assignment operator (+=)
var oldValue = "apples";
oldValue += " and oranges"; // string now has "apples and oranges"
// alternative using the built-in String method .concat