Addition Operator (+)
Summary
Adds two numbers.
Syntax
expression1 + expression2
Parameters
- expression1
- An expression that evaluates to a number.
- expression2
- An expression that evaluates to a number.
Description
For numeric data, the +
operator adds two numbers. For example, 2 + 2
will evaluate to the result 4
.
Differences from JavaScript
In JS++, arithmetic cannot be performed on Booleans. In JavaScript, for these operations,
false
is treated as 0 andtrue
is treated as 1.In JS++, arithmetic operations cannot be performed on
null
. In JavaScript,null
is treated as 0.In JS++,
undefined
cannot be used in arithmetic operations. In addition,NaN
can never occur from integer arithmetic. In JavaScript, an arithmetic expression that evaluates toundefined
orNaN
results inNaN
for the result.
Examples
1 2 3 4 | import System; Console.log(1 + 1); // 2 Console.log(2 + 2); // 4 |
See Also
- Concatenation Operator (+)
- Subtraction Operator (-)
- Multiplication Operator (*)
- Division Operator (/)
- Modulus Operator (%)
- Types
- Operator Precedence
Share
HTML | BBCode | Direct Link