Subtract operator

Category:Math

Subtract operator

Category: Math

Subtracts two numbers.

All programming languages support the basic arithmetic operations of addition, subtraction, multiplication and division of numbers.

Examples


// Subtract two numbers.
console.log(3-5);
var x=3;
var y=5;
console.log(x-y);

Found a bug in the documentation? Let us know at documentation@code.org

Syntax

value1 - value2

Parameters

NameTypeRequired?Description
Name any The operands can be a number, or a variable containing a number, or the number returned by a function, or the numeric result of the evaluation of an expression.

Returns

The difference of two numbers.

Tips

  • Operator precedence is the same as standard arithmetic - Expressions within a parentheses have the highest precedence, then multiplcation and division, then addition and subtraction.

Found a bug in the documentation? Let us know at documentation@code.org