The getFloatValue() method of the CSSPrimitiveValue interface is used to get a float value in a specified unit. If this CSS value doesn't contain a float value or can't be converted into the specified unit, a DOMException is raised.
Syntax
var floatValue = cssPrimitiveValue.getFloatValue(unit);
Parameters
unitType
An unsigned short representing the code for the unit type, in which the value should be returned. Valid values are:
An INVALID_ACCESS_ERR is raised if the CSS value doesn't contain a float value or if the float value can't be converted into the specified unit.
Example
var cs = window.getComputedStyle(document.body);
var cssValue = cs.getPropertyCSSValue("margin-top");
console.log(cssValue.getFloatValue(CSSPrimitiveValue.CSS_CM));