---
title: Unary negation (-)
slug: Web/JavaScript/Reference/Operators/Unary_negation
tags:
  - JavaScript
  - Language feature
  - Operator
  - Reference
browser-compat: javascript.operators.unary_negation
---
{{jsSidebar("Operators")}}

The unary negation operator (`-`) precedes its operand and negates it.

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

## Syntax

```js
-x
```

## Examples

### Negating numbers

```js
const x = 3;
const y = -x;

// y = -3
// x = 3
```

### Negating non-numbers

The unary negation operator can convert a non-number into a number.

```js
const x = "4";
const y = -x;

// y = -4
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- [Addition
  operator](/en-US/docs/Web/JavaScript/Reference/Operators/Addition)
- [Subtraction
  operator](/en-US/docs/Web/JavaScript/Reference/Operators/Subtraction)
- [Division
  operator](/en-US/docs/Web/JavaScript/Reference/Operators/Division)
- [Multiplication
  operator](/en-US/docs/Web/JavaScript/Reference/Operators/Multiplication)
- [Remainder
  operator](/en-US/docs/Web/JavaScript/Reference/Operators/Remainder)
- [Exponentiation
  operator](/en-US/docs/Web/JavaScript/Reference/Operators/Exponentiation)
- [Increment
  operator](/en-US/docs/Web/JavaScript/Reference/Operators/Increment)
- [Decrement
  operator](/en-US/docs/Web/JavaScript/Reference/Operators/Decrement)
- [Unary plus
  operator](/en-US/docs/Web/JavaScript/Reference/Operators/Unary_plus)
