DEV Community

Discussion on: Three dots ( … ) in JavaScript

Collapse
 
albertywu profile image
Albert Wu

Great article! This was a really great explanation of spread/rest.

I'd also add that three dots on the left-side of an equals sign is "destructuring assignment" and allows you to "pull out" values.

ex:

[a, b, ...rest] = [10, 20, 30, 40, 50];
console.log(rest); // [30,40,50]

let {a, b, ...rest} = {a: 10, b: 20, c: 30, d: 40}
console.log(a); // 10 
console.log(b); // 20 
console.log(rest); // { c: 30, d: 40 }
Enter fullscreen mode Exit fullscreen mode
Collapse
 
sagar profile image
Sagar

I missed writing about destructor. Thanks