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);
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);
Top comments (0)