Operators JavaScript Tutorial

Syntax

variable += value


    
    
    

Additive operators also behave in special ways when dealing with special values. If the two operands are numbers, they perform an arithmetic add and return the result according to these rules:
If either number is NaN, the result is NaN.
If Infinity is added to Infinity, the result is Infinity.
If –Infinity is added to –Infinity, the result is –Infinity.
If Infinity is added to –Infinity, the result is NaN.
If +0 is added to +0, the result is +0.
If –0 is added to +0, the result is +0.
If –0 is added to –0, the result is –0.
If, however, one of the operands is a string, then the following rules are applied:
If both operands are strings, the second string is concatenated to the first.
If only one operand is a string, the other operand is converted to a string and the result is the concatenation of the two strings.