function
default value
(function(x = 'foo') {
console.log('Hello ' + x);
})();
// Hello foo
rest
Using in function declaration parameters
Example:
function func(a, b, ...args) {
console.log(args.length);
}
func(1, 2, 3, 4); // 2
spread
Using in function(variable); Example:
function add(x, y) {
return x + y;
}
let nums = [2, 3];
let result = add(...nums);
console.log(result); // 5
Do more in array~
Can replace the apply
in array;
arrayA.concat(arrayB) => arrayA = [...arrayA, ...arrayB];