rest parameter 和 Destructuring assignment.
function fun1(...theArgs) {
console.log(theArgs.length);}// theArgs is an array
fun1(); // 0
fun1(5); // 1fun1(5, 6, 7); // 3function f(a, b, ...theArgs) {
// ...}function f(...[a, b, c]) {
return a + b + c;}f(1) // NaN (b and c are undefined)
f(1, 2, 3) // 6f(1, 2, 3, 4) // 6 (the fourth parameter is not destructured)见 ECMAScript 6 (2015)
Arrow function * 简洁的语法, * 没有自己的this, arguments, super 和 new.target. 特别适用于非属性函数,不能用作构造函数. function Person(){ this.age = 0;setInterval(() => {
this.age++; // |this| properly refers to the person object }, 1000);}var p = new Person();