CKTIS / JavaScript
Subtraction operator (-)
The binary `-` operator subtracts the right operand from the left. It converts operands to numeric values and supports either `Number` or `BigInt`, but does not allow those types to be mixed.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
left - rightThe expression left - right returns the difference: the right operand is subtracted from the left. Binary subtraction differs from unary -value, which negates a value. Subtraction itself does not assign its result to either operand.
The operator converts operands using ToNumeric. Two Number values produce a Number, and two BigInt values produce a BigInt. Mixing those types, as in 10n - 3, throws TypeError; an explicit conversion is needed. Unlike +, - does not concatenate strings: "10" - 3 produces 7, whereas "hello" - 3 produces NaN.
Subtraction is left-associative: 10 - 3 - 2 means (10 - 3) - 2. Multiplication has higher precedence. Number calculations can involve floating-point rounding; BigInt provides exact integer subtraction.
Examples
console.log(10 - 3);
console.log("10" - 3);
console.log(String(10n - 3n));
console.log(Number.isNaN("hello" - 3));
try {
console.log(10n - 3);
} catch (error) {
console.log(error.name);
}Result
7 7 7 true TypeError
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.