/

HTML / CSS / JavaScript Tutorial

JavaScript Operator: plus assignment

[this page | pdf | back links]

In JavaScript, the += operator is the assignment operator with addition (if arithmetic) or concatenation (if string).

 

Arithmetic operator

 

For example, if x is 5 and y is 8 then y += x results in x remaining 5 and y = y + x, so y becomes 13.

 

String operator

 

For example, if x is "a" and y is "b" then y += x results in x remaining "a" and y = y + x, so y becomes "ba".

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript Operators


Desktop view | Switch to Mobile