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 and true 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 to undefined or NaN results in NaN for the result.

Examples

Basic Usage
1
2
3
4
import System;
 
Console.log(1 + 1); // 2
Console.log(2 + 2); // 4

See Also

Share

HTML | BBCode | Direct Link