--- title: Subtraction (-) slug: Web/JavaScript/Reference/Operators/Subtraction translation_of: Web/JavaScript/Reference/Operators/Subtraction ---
{{jsSidebar("Operators")}}

The subtraction operator (-) subtracts the two operands, producing their difference.

{{EmbedInteractiveExample("pages/js/expressions-subtraction.html")}}

语法

Operator: x - y

Examples

Subtraction with numbers

5 - 3     // 2
3 - 5     // -2

Subtraction with non-numbers

'foo' - 3 // NaN

Specifications

Specification
{{SpecName('ESDraft', '#sec-subtraction-operator-minus', 'Subtraction operator')}}

Browser compatibility

{{Compat("javascript.operators.subtraction")}}

See also