Talking about ES6

Source: Internet
Author: User

I was amazed by the simplicity of the code, which was contacted by Coffeescript in 15. I wrote JavaScript before, but found it too redundant and basically no motivation to continue writing. 16 began to contact react and react Native, also formally understand the ES6 grammar, found it and coffeescript very close, and has a great improvement. These days refer to http://es6-features.org/, to ES6 re-simple study, have the following considerations.

ES6 support for the new features are:
1. Constants
Constants, this is not much to say, most languages have, such as C,c++,java,go and so on. Python was not there before, with some support in PEP8. After adding constants, although not as flexible as before, the constants do type checking and speed up compilation.
2. = = function definition
The/= function definition, similar to the function binding in Coffeescript, can dynamically bind the This keyword in JavaScript to the object on which the current function hangs. /= bind to make the original function binding easier. At the same time, because the syntax of ES6 need to use {} () for code segmentation, so that the code compared to coffeescript more clear, easy to read.
3. Templates
Template, which automatically supports the template mechanism, is ES5 than before, and does not require additional template engines to be introduced.
4. Extended parameter handling
5. Deconstruction Assignment
Extended parameter processing, is very good, with ... To extend the parameters, similar to the go syntax. Relatively easy to understand. In addition, in the function deconstruction assignment, it is also similar to go, which supports multi-variable assignment and default parameters.
6. Module
is an abstraction. Similar to the concept of package or namespace.
7. Class (Maximum improvement)
Finally began to support object-oriented programming, support for inheritance, as well as static functions and other related operations;
8. Iterators and Generators
Iterations and generators, I understand iterator in C + +, and iterations and generators in Python. But the sense of grammar is still somewhat complicated and hopefully can be improved later.
9. Map/set/weakmap/weakset
Further support for data functions
10. Inline functions
Provides more internal function encapsulation, which is implemented mainly with modules and object-oriented.
Promise.
For better encapsulation of asynchronous operations, react can already be used directly in react-native.
12. Reflection mechanism
Reflection mechanism similar to reflect in go, or typeof mechanism
13. Internationalization and Localization support
This is good, and it's supported in other languages.
and other

ES6 syntax makes JS more and more easy to learn, also has the universality, I feel more deep, above is and other several grammar analysis and contrast. Of course, younger brother skill is still shallow, what insufficient support, please many criticize correct.

Talking about ES6

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.