React Getting Started-babel

Source: Internet
Author: User
Tags versions

Many computer languages are running, we need to compile the source code to the computer at the bottom of the language;

While JavaScript is an interpreted language, the browser receives JavaScript text and then interprets execution, so after writing JavaScript code, the browser can directly recognize the text without having to compile JavaScript text.

However, with the continuous updating and versioning of JavaScript, new syntax and features are becoming more and more numerous. These syntaxes provide a better performance, programming experience, and development style, and browsers follow the new syntax and features very slowly, meaning that the new JavaScript features are not directly available.

This is the background of Babel's appearance.

The versions of JavaScript include ES3, ES5, ES6, and ES7, and not all browsers support all of these versions.

In order to allow developers to use the latest JavaScript version after the advent of new versions of JavaScript, Babel appears.

Babel allows developers to develop applications using the latest JavaScript version and new syntax. It can convert the latest syntax into a syntax that all browsers can support today.

For example, you can now use the new syntax of ES6 and even ES7, and of course, react JSX syntax, and use Babel to translate these syntaxes into ES5 syntax that the current browser can support.

In the previous article, Babel was referenced directly in the browser:

<script src= "Https://unpkg.com/babel-standalone@6.15.0/babel.min.js" ></script>

Then, write the JSX JavaScript code in the script label with type Text/babel:

<script type= "Text/babel" >
function formatname (user) {return
  User.firstname + ' + user.lastname;
}

Const USER = {
  firstName: ' Harper ',
  lastName: ' Perez '
};

const ELEMENT = (
  

In the product mode, this method is not suitable for use.

Babel can also provide transformations in loader ways in tools such as Webpack.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.