Arithmetic Operators (+) : Arithmetic operator : Operators JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Operators » Arithmetic operator »

 

Arithmetic Operators (+)















All the common arithmetic operators will attempt to convert strings to numbers when applicable.

If a string cannot be converted to a number, NaN (Not A Number) will be returned.

Addition (+)

If the values on either side are numerical values, the values are added together.

IF the values are strings, they are concatenated together.

The following line of code








var resultOfAdd = 34 12;



would set the variable resultOfAdd equal to 46








var resultOfAdd = "a" "b";



would set the variable resultOfAdd equal to the string "ab".





HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Operators
» Arithmetic operator