An ESnext spec-compliant Math.trunc
shim/polyfill/replacement that works as far down as ES3.
This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec.
npm install --save math.trunc
console.log(Math.trunc(42.84); // 42
console.log(Math.trunc(0.123); // 0
console.log(Math.trunc(-0.123); // -0
Simply clone the repo, npm install
, and run npm test