A method to convert the argument to an integral numeric value. This method follows ECMAScript's specification for the 'ToInteger' abstract operation.
npm install es-abstract-to-integerA 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 install es-abstract-to-integer
`javascript
var toInteger = require('es-abstract-to-integer')
console.log(toInteger(-3.14)) // => -3
console.log(toInteger(3.14)) // => 3
console.log(toInteger(42)) // => 42
console.log(toInteger("9001")) // => 9001
console.log(toInteger(null)) // => 0
console.log(toInteger(false)) // => 0
console.log(toInteger(true)) // => 1
console.log(toInteger("foo")) // => 0
console.log(toInteger({})) // => 0
console.log(toInteger([])) // => 0
var d = new Date(2015, 3, 14, 0, 0, 0, 0)
console.log(toInteger(d)) // => 1428984000000
`
- API
- ECMAScript Specification References
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 ObjectsvalueOf
that lack a method or a toString method capable of returning a
non-object value.
#### argument
Type: *`
The value to convert.
- es-abstract: a single library
for multiple ECMAScript abstract operations.