Open utterances-bot opened 4 years ago
very insightful thanks !!
It's a very informative article
Nice article but misses 2 useful tricks:
const o = { a: 1 }
const name = 'a'
const { [name]: value } = o
console.log(value) // 1
* **arguments skipping**
```js
function getThird(...[,,third]) {
return third
}
console.log(getThird(1, 2, 3)) // 3
When needing immutability, I find the spread syntax overly verbose compared to this:
deepCopy = (obj) => { return JSON.parse(JSON.stringify(obj)) }
@alexleduc76 Except that: your deep copy doens't preserves the methods, prototypes chain, map, etc.
@Lcfvs That's true, however I have never had a need to deep copy anything but objects and arrays containing primitive values.
(except nested array and objects of course.)
Thank you, great post.
Understanding Destructuring, Rest Parameters, and Spread Syntax | Tania Rascia
This article was originally written for DigitalOcean. Introduction Many new features for working with arrays and objects have been made…
https://www.taniarascia.com/understanding-destructuring-rest-spread/