Concatenates string values together using the concatenation operator (+) or the shorthand assignment operator (+=).
- Strings are created using the global object constructor
new String()or created as string primitives.
- String literals are string primitives and are created by enclosing some value in single or double quotes.
There are a few things to remember when concatenating strings together:
The following code should shed light on the above.
// Create a string and numeric variables. var aString = '5'; var aNumber = 5; // Concatenation ends up with a string holding the value '55' not 10. alert(aString + aNumber);