Note: This feature is available in Web Workers.
The to() method of the CSSNumericValue interface converts a numeric value from one unit to another.
to(unit)unitThe unit to which you want to convert.
A CSSUnitValue.
SyntaxError DOMExceptionThrown if an invalid unit was passed to the method.
TypeErrorThrown if:
CSSNumericValue on which the method is being called can't be resolved to a single value and type. This might occur if the value is calculated from a variable when the value of that variable can't be known in the context.// Prints "0.608542cm"
console.log(CSS.px("23").to("cm").toString());