ToInteger
A method to convert the argument to an integral numeric value. This method follows ECMAScript's specification for the 'ToInteger' abstract operation.
Currently, this module only supports the ES2017 (ES8) specification.
npm
Installation Usingnpm install es-abstract-to-integer
Example Usage
var toInteger = console // => -3console // => 3console // => 42console // => 9001console // => 0console // => 0console // => 1 console // => 0console // => 0console // => 0 var d = 2015 3 14 0 0 0 0console // => 1428984000000
Documentation
API
ToInteger ( argument )
The abstract operation ToInteger converts argument to an integral numeric value.
A Number value is returned.
A TypeError
exception may be thrown for arguments that are Symbols or Objects
that lack a valueOf
method or a toString
method capable of returning a
non-object value.
argument
Type: *
The value to convert.
Related Projects
- es-abstract: a single library for multiple ECMAScript abstract operations.