Skip to content

toInt

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

Usage

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

Installation

Terminal window
npx atmx add helper toInt