Note: This feature is available in Web Workers.
The CSSMathNegate() constructor creates a new CSSMathNegate object which negates the value passed into it.
new CSSMathNegate(arg)argA number or CSSNumericValue that represents the value to negate.
None.
The following code creates a CSSMathNegate object from a length, then logs the constructor name, value, and the object's serialization (from toString()).
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, the value is rectified to a CSSUnitValue with unit "number":
const negatedNumber = new CSSMathNegate(4);
console.log(negatedNumber.value); // CSSUnitValue {value: 4, unit: "number"}