Lesson 28 / 30
Common Interview Questions
Essential Babel and SWC concepts for tech interviews.
Quick check: What is the primary purpose of Babel?
- To convert modern JavaScript to ES5-compatible syntax for older browsers
- To minify and compress JavaScript files
- To bundle multiple files into one
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: Why is SWC faster than Babel?
- SWC skips transpilation of large files
- SWC is written in Rust and compiled to native code, while Babel is interpreted JavaScript
- SWC doesn't transpile JSX or TypeScript
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: Can Babel add runtime features that don't exist in the target browser?
- Yes, always
- No, Babel can only transpile syntax; runtime features require polyfills
- Yes, but only for Promise and Array methods
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.