Polyfill

Polyfill provides new api to support old browsers. For example, some old browsers doesn't have Math.trunc.

We have this as the polyfill:

if (!Math.trunc) { // if no such function
  // implement it
  Math.trunc = function(number) {
    // Math.ceil and Math.floor exist even in ancient JavaScript engines
    // they are covered later in the tutorial
    return number < 0 ? Math.ceil(number) : Math.floor(number);
  };
}

Example: Polyfill.io, zloirock/core-js: Standard Library (github.com)