1. ES6解決了函數的默認參數的問題:
~~~
function(url, timeout = 2000, callback = function() {}) {
// do somthing
};
~~~
2. ES6默認參數不在argument對象之內;
~~~
function(first, second = 'b') {
console.log(arguments.length); // 1
console.log(first === arguments[0]); // true
console.log(second === arguments[1]) // false
};
~~~