Polyfills and Transpilers in JavaScript

1. Transpilers

Transpiler is a special piece of software that can parse (“read and understand”) modern code, and rewrite it using older syntax constructs so that the result would be the same.

2. Polyfills

New language features may include not only syntax constructs and operators but also built-in functions.

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);



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhay Jain

Abhay Jain

Developer with 3 yrs of industrial experience in developing scalable web applications.