String concatenate (+) (Operator/string)

Joins two string values together.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise server - 2.0
Opera - 3.0
Property/method value type:String primitive
JavaScript syntax:-aString1 + aString2
Argument list:aString1A string value
aString2Another string value

When the operands are a pair of strings, the plus sign will concatenate them together. This yields a single string combining both values joined end to end.

The string concatenation is not commutative. That is, the position of the two operands will affect the outcome if they are exchanged.

The addition/concatenation operator looks at the arguments and if either is a String already or preferentially converts to one, then a concatenation occurs. If neither argument prefers to be a String then a Number conversion happens and the values are added.

The associativity is left to right.

Refer to the operator precedence topic for details of execution order.

Warnings:

See also:Add (+), Additive operator, Array.join(), Array.toString(), Associativity, Operator Precedence, parseFloat(), parseInt(), String value, String type, String literal, String object, String operator, String.split(), ToString, toString(), Type conversion

insert figure 0021

Cross-references:

ECMA 262 edition 2 - section 11.6.1

ECMA 262 edition 3 - section 11.6.1

Wrox Instant JavaScript - page 37