Lesson 34 of 55
javascriptTranspiling with Babel – ES6 → ES5
10 mins
Course progress62%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 34 of 55
javascript10 mins
Keep these ideas in mind as you work through the lesson.
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
const name = user?.profile?.name ?? 'Guest';
Babel will transform it to safe property checks for browsers that don’t support the syntax.