DEV Community

Cover image for Babel Basic - Javascript
Ganesh Raja
Ganesh Raja

Posted on • Edited on

2 2

Babel Basic - Javascript

I wasn't able to share yesterday's post due to some work. But yesterday I mainly worked on Babel Basics.

So basically bable is a transpiler used to convert ES6+, javascript version into ES5. we have presets to convert typescript,react into Es5 code as well.Explored about how to use babel plugins and the difference between preset and a plugin and other stuffs. It was very interesting thing to learn.

You can find the series repo here
https://github.com/ganeshraja10/Latest-Tech-Learnings

written code

multiplyBy2 = (arr) => arr.map((item) => item * 2);

let arr = [1, 2, 3];

console.log(multiplyBy2(arr));

let element = 22;
console.log(element ?? -1);

Enter fullscreen mode Exit fullscreen mode

After transpiling to Es5

"use strict";

multiplyBy2 = function multiplyBy2(arr) {
  return arr.map(function (item) {
    return item * 2;
  });
};

var arr = [1, 2, 3];
console.log(multiplyBy2(arr));
var element = 22;
console.log(element !== null && element !== void 0 ? element : -1);

Enter fullscreen mode Exit fullscreen mode

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs