If you are already working in JavaScript, you might know that some new features were added in ECMA Script in 2015–2016 including promises, fetch APIs, and ES Module System. Why are we telling you this? Well, whenever new features are added to JavaScript, browsers must update their JavaScript engines so that they can understand the code. Otherwise, your code won’t run.
But, how to make sure that your codes run irrespective of the browser? For that, you need to use Babel.js. It’s basically a JavaScript compiler that can convert JavaScript code containing the latest features to older versions of JavaScript.
In short, Babel makes sure that the latest features are properly compiled and rendered on every browser.
For instance, if you are using arrow functions in your code then Babel will convert it into a function that even older versions of the browser can understand.
Now, as per their official website, Babel does the following:
- It transforms the syntax of modern JavaScript into a version understandable by old browsers.
- Babel polyfills features that are not present in your target environment. This means that if some methods or objects are newly added, Babel will not only polyfill but also transpile. So, you see for a reason Babel is called a transpiler. And honestly, Babel is useful.
I would say: Good job, Sebastian McKenzie. This is because he developed Babel.
Now, what are the advantages of using Babel? There are many. One of the best advantages of using Babel is its backward compatibility. You don’t have to worry about your code not working in any browser.
Moreover, you can use Babel with gulp, webpack, flow, react, and typescript. Not only this, Babel also works with react JSX syntax. It can even be compiled in JSX form. But, you see that even the sun has spots. There are disadvantages to using Babel. The fact that Babel code changes the syntax while transpilation makes the code difficult to understand. The size of the code that is transpiled can be increased as well.
So, should you learn Babel? Well, Babel isn’t a language to understand or even learn. Babel just make your code understandable by old browsers. And it’s absolutely worth it to use Babel. YouTube videos, coding platforms, and beginner-friendly courses will help you to learn Babel.
Top comments (0)