Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Transpiling with Babel – ES6 → ES | JavaScript Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. JavaScript Course

Lesson 34 of 55

·javascript

Transpiling with Babel – ES6 → ES5

10 mins

Course progress62%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • Set **targets** in `preset-env` to control which browsers are supported (`{targets: '> 0.25%, not dead'}`).
  • Include **polyfills** (`core-js`) for features that cannot be transpiled (e.g., `Promise`).
  • Use **source maps** (`sourceMaps:true`) for easier debugging of transformed code.

Babel converts modern JavaScript into a version compatible with older browsers.

npm install --save-dev @babel/core @babel/cli @babel/preset-env

.babelrc

{
  "presets": ["@babel/preset-env"]
}

Run:

npx babel src --out-dir lib

Example: Optional chaining (needs Babel)

const name = user?.profile?.name ?? 'Guest';

Babel will transform it to safe property checks for browsers that don’t support the syntax.

Make it stickPractice what you've learned1 quiz · 7 practical tests · Optional activities from JavaScript CourseBrowse activities
Previous lessonWeb Components – Custom Elements, Shadow DOM & TemplatesContinue to lesson 35Memory Management – Garbage Collection & LeaksBack to JavaScript Course curriculum