Favorites

JavaScript - Subtraction Operator

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
-
JavaScript Arithmetic OperatorThis operator is supported by all modern browsers.
Updated 28th November 2026

The subtraction operator (-) subtracts one number from another.

Description

The subtraction operator - subtracts the right operand from the left. Unlike +, it always converts both operands to numbers, so '10' - 2 is 8, and non-numeric strings give NaN. Subtracting two Date objects gives the difference in milliseconds.

Because subtraction always converts to numbers, it's sometimes used to turn a numeric string into a number, but Number(value) states the intent more clearly. Booleans become 1 and 0, null becomes 0, and undefined becomes NaN, so 5 - undefined is NaN. With decimals, results can show floating point rounding, such as 0.3 - 0.1 giving 0.19999999999999998.

Subtraction also works with BigInt values, as long as both operands are BigInts. It is left-associative and has the same precedence as addition, so 10 - 2 - 3 is 5. The compound form x -= y subtracts and assigns in one step, and the unary minus, -x, negates a single value.

Properties

Operator
-
Category
Arithmetic
Precedence
11 (1 is lowest, 18 is highest)
Associativity
left-to-right

Syntax

x - y

Example

console.log(10 - 4);
console.log('10' - 2);
console.log('abc' - 1);
console.log(new Date(2026, 0, 2) - new Date(2026, 0, 1));

Browser Support

The following information will show you the current browser support for the - operator. Hover over a browser icon to see the version that first introduced support for this operator.

This operator is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee