Skip to content

toFloat

Combines `Number.parseFloat` with NaN handling. By default, a zero (0) is returned in place of NaN.

Usage

toFloat("1.23"); // => 1.23
toFloat("foo"); // => 0
toFloat("1.23px", 1); // => 1.23
toFloat("foo", 1); // => 1

Installation

Terminal window
npx atmx add helper to-float