ECMAScript6已经逐渐成为JavaScript开发最普及的标准之一,我想回顾一下ES6的新特性:

常量: const
//es6写法:
const Pi = 3.14

//es5写法:
Object.defineProperty(typeof global === "object" ? global : window, "PI", {
    value:        3.141593,
    enumerable:   true,
    writable:     false,
    configurable: false
})
块级作用域变量let、const
箭头函数
//es6
odds = evens.map(item => item + 1);

//es5
odds = evens.map(function(item) {
    return item + 1;
});
默认参数
function f (x, y = 7, z = 42) {
    return x + y + z;
}
rest
function f (x, y, ...a) {
    return (x + y) * a.length;
}
f(1, 2, "hello", true, 7) === 9;
结构赋值
let [a, b, c] = [1, 2, 3];
标签字符串
let name = 'Rain';
let message = `Hello ${name};
参考链接:http://es6-features.org/#StringInterpolation

未完待续