CSSMathNegate: CSSMathNegate() constructor
CSS Typed Object Model API
CSS Typed Object Model API
The **`CSSMathNegate()`** constructor creates a new CSSMathNegate object which negates the value passed into it.
## Syntax
```js-nolint
new CSSMathNegate(arg)
```
### Parameters
- `arg`
- : A number or CSSNumericValue that represents the value to negate.
### Exceptions
None.
## Examples
### Basic usage
The following code creates a `CSSMathNegate` object from a length, then logs the constructor name, `value`, and the object's serialization (from toString()).
```js
const negated = new CSSMathNegate(CSS.px(10));
console.log(negated.constructor.name); // "CSSMathNegate"
console.log(negated.value); // CSSUnitValue {value: 10, unit: "px"}
console.log(negated.toString()); // "calc(-10px)"
```
Note that if a plain number is passed to `arg`, it's converted to a CSSUnitValue whose unit is `"number"`:
```js
const negatedNumber = new CSSMathNegate(4);
console.log(negatedNumber.value); // CSSUnitValue {value: 4, unit: "number"}
```
## Specifications
## Browser compatibility
Cite this
"CSSMathNegate: CSSMathNegate() constructor". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/CSSMathNegate/CSSMathNegate JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy