This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

addition

Summary

Adds the value of one numeric expression to another, or concatenates two strings.

Syntax

result = expression1 + expression2;
result
Any variable.
expression1
Any expression.
expression2
Any expression.

Examples

console.log(1 + 1); // 2
console.log('hello' + ' world'); // 'hello world'
console.log(1 + '1'); // '11'
console.log('1' + 1); // '11'

Remarks

The types of the two expressions determine the behavior of the + operator.

IfThen
Both expressions are numeric or BooleanAdd
Both expressions are stringsConcatenate
One expression is numeric and the other is a stringConcatenate

See also

Other articles

Attributions

  • Microsoft Developer Network: Article