Favorites

JavaScript -x Unary negation Operator

☕
Enjoying this site?

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

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

The unary negation operator (-) placed before a value converts it to a number and flips its sign.

Description

The unary negation operator - converts its operand to a number and returns its negative. It also works with BigInts.

Like unary plus, the value is converted to a number before it's negated, so -'5' is -5 and -'abc' is NaN. Negating zero gives -0, which is equal to 0 with === but can be told apart with Object.is() and shows up in results such as 1 / -0 being -Infinity.

Because unary operators can't appear directly before the base of an exponentiation, -2 ** 2 is a syntax error; write -(2 ** 2) or (-2) ** 2. To get the absolute value, the opposite of negation, use Math.abs().

Properties

Operator
-x
Category
Unary
Precedence
14 (1 is lowest, 18 is highest)
Associativity
right-to-left

Syntax

-x

Example

const x = 4;
console.log(-x);
console.log(-'7');
console.log(-(-3));

Browser Support

The following information will show you the current browser support for the -x 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