ES6

作者: Cesium4Unreal | 来源:发表于2018-12-16 18:08 被阅读0次

    What is ES6?

    6th Edition - ECMAScript 2015
    https://en.wikipedia.org/wiki/ECMAScript#6th_Edition_-_ECMAScript_2015

    ECMA-262
    http://www.ecma-international.org/publications/standards/Ecma-262.htm

    Compatibility tables
    http://kangax.github.io/compat-table/es6/

    Can I use ES6
    https://caniuse.com/#search=es6

    ECMAScript 6: Feature Overview & Comparison
    http://es6-features.org/

    let, const

    let: Declare a variable with block scope
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let

    const: Declare a constant variable with block scope
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const

    never use var

    jshint option varstmt
    http://jshint.com/docs/options/#varstmt

    Classes

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
    • syntactical sugar
    • constructor
    • extends
    • super
    • static method

    Module

    <script type="module" src="js/demo.js"></script>
    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-type

    <script nomodule src="js/demo-iife.js"></script>
    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-nomodule

    Fallback
    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#Module_Fallback

    import
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

    export
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export

    More features

    Arrow functions
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

    Template literals
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

    Default parameters
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters

    Rest parameters
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters

    Spread syntax
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax

    Promises
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises

    Destructuring assignment
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

    Enhanced Object literals
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Enhanced_Object_literals

    ES6 是 ECMAScript 6.0 的简写,即 JavaScript 语言的下一代标准,已经在 2015年6月正式发布了,它的目标是让JS能够方便的开发企业级大型应用程序,因此,ES6的一些规范正在逐渐向Java、C# 等后端语言标准靠近。在 ES6 规范中,比较重大的变化有以下几个方面:

    新增 let、const 命令 来声明变量,和var 相比,let 声明的变量不存在变量提升问题,但没有改变JS弱类型的特点,依然可以接受任意类型变量的声明;const 声明的变量不允许在后续逻辑中改变,提高了JS语法的严谨性。
    新增解构赋值、rest 语法、箭头函数等,这些都是为了让代码看起来更简洁,而包装的语法糖。
    新增模块化机制,这是 JavaScript 走向规范比较重要的一步,让前端更方便的实现工程化。
    新增类和继承的概念,配合模块化,JavaScript 也可以实现高复用、高扩展的系统架构。
    新增模板字符串功能,高效简洁,结束拼接字符串的时代。
    新增 Promise 机制,解决异步回调多层嵌套的问题。

    相关文章

      网友评论

        本文标题:ES6

        本文链接:https://www.haomeiwen.com/subject/ebyxkqtx.html