Lesson 29 / 31

Common Interview Questions

Review Babel and SWC concepts commonly asked in interviews, from transpiling versus bundling to polyfills.

Quick check

Quick check: What is the primary purpose of Babel?

  • To minify and compress JavaScript files
  • To bundle multiple files into one
  • To convert modern JavaScript to ES5-compatible syntax for older browsers
  • To manage npm packages
Answer

To convert modern JavaScript to ES5-compatible syntax for older browsers — Babel transpiles modern JavaScript to compatible older syntax. Minification and bundling are separate concerns handled by other tools.

Quick check

Quick check: Why is SWC faster than Babel?

  • SWC skips transpilation of large files
  • SWC doesn't transpile JSX or TypeScript
  • SWC removes all comments
  • SWC is written in Rust and compiled to native code, while Babel is interpreted JavaScript
Answer

SWC is written in Rust and compiled to native code, while Babel is interpreted JavaScript — SWC's Rust implementation enables massive performance gains. Compiled native code is far faster than interpreted JavaScript for CPU-intensive parsing and AST transformation.

Quick check

Quick check: Can Babel add runtime features that don't exist in the target browser?

  • No, Babel can only transpile syntax; runtime features require polyfills
  • Yes, always
  • Yes, but only for Promise and Array methods
  • Only in Chrome
Answer

No, Babel can only transpile syntax; runtime features require polyfills — Babel transpiles syntax but cannot create functions that don't exist. For runtime features like `Promise.all()` or `Array.prototype.includes()`, use polyfills like core-js.