New Blog (Beta)
https://grimmer.netlify.com
c=[...a]
c= {...a, ...b}
rest operator:...
, 變成一個, for destructuring arrays and objects
ES6 rest parameters: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters
function fun1(...theArgs) {
console.log(theArgs.length);
}
Destructuring_assignment https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment Array destructuring
[a, b, ...rest] = [1, 2, 3, 4, 5];
是Rest operator, ES6
Object destructuring c = {a:1, b:2};
{a, b} = c
or
({a, b} = {a:1, b:2})
其他:
var c= {a,b} -> ES6
用來測試的: http://ES6console.com/
Leave a Comment