Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
716 views
in Technique[技术] by (71.8m points)

babeljs - Why do I need Babel JS?

I'm struggling to understand the importance of Babel here... So ES6 comes along and gives us fat arrow functions, shorter syntax etc. so why do we need to compile ES6 into traditional JS? Is it because there are older browsers out there that can't interpret new JS syntax? Or does it have something to do with keeping source code consistent? Bit of a noob question I know - but hey, I am noob! Any insight appreciated!

question from:https://stackoverflow.com/questions/39401836/why-do-i-need-babel-js

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

While the answers here are all correct, Babel is not just about ES6 (ES2015). The ECMA standards committee has agreed to release yearly updates to the JavaScript language. Babel will always integrate the standards, whereas we don't know if all the browsers will, and if they do, whether they will be able to keep up with the changing standards.

With a transpiler like Babel, we can stay ahead of the web browsers and use new features of ECMAscript when they are released instead of waiting for the browser manufacturers to integrate the features, use polyfills, or whatever else. It also allows the end user to customize the features that they want to use and build their own version of the language.

To hear the creator of Babel talk about this, you can listen to this JavaScript Jabber episode.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...