๐Ÿ•ฐ๏ธ JavaScript

Polyfills vs Transpilers โ€” How New JS Runs in Old Browsers

๐Ÿ“… Jul 4, 2026 โฑ 2 min read

A tidy interview question with a tidy answer: transpilers rewrite SYNTAX; polyfills add missing FUNCTIONS.

Transpiling (Babel/esbuild)

// you write:
const greet = (name = "friend") => `Hi ${name}`;

// old-browser output:
var greet = function (name) {
  if (name === undefined) name = "friend";
  return "Hi " + name;
};

Arrow functions, classes, ?. โ€” syntax an old parser would choke on gets rewritten at build time.

Polyfilling

// Array.prototype.at is a FUNCTION, not syntax โ€” patch it at runtime:
if (!Array.prototype.at) {
  Array.prototype.at = function (i) {
    return this[i < 0 ? this.length + i : i];
  };
}

fetch, Promise, IntersectionObserver in ancient browsers โ€” all polyfills. This is also the practical use of prototypes (see that guide).

The 2026 reality

Check any feature's support at caniuse.com โ€” the tab every frontend dev keeps open.

โ† All Articles