Question Bank
/

JavaScript Tooling and Build Trivia

JavaScript Tooling and Build Trivia

Three quick-fire build-pipeline questions: transpiler vs polyfill, Babel vs SWC, and what source maps actually do.

Question Bank
Easy
JavaScript
3 questions
quiz
js-language
interview-prep
fundamentals

1,029 views

30

Explain the difference between a transpiler (e.g. Babel) and a polyfill. Give one concrete example of each.

Examples

Example 1:

Input: target browser doesn't understand class syntax or Array.prototype.includes
Output: Babel transpiles `class` to constructor functions; core-js polyfills `Array.prototype.includes` at runtime.
Explanation: A transpiler rewrites syntax; a polyfill adds missing runtime APIs.
// Source written with modern JS:
// let total = 10;
// let sum = total ?? 100;

// Babel transpiles it to (roughly):
'use strict';
var total = 10;
var sum = total !== null && total !== void 0 ? total : 100;