3 ms·
Destructuring assignments are extremely useful, especially within function signatures.
by btdiehr 11y ago
Destructuring assignments are extremely useful, especially within function signatures.
- th0br0 11y agoWithout knowing the type of what you're destructuring though, that's quick to land you in some type of undefined hell.
- btdiehr 11y agoWhy wouldn't you know what your destructuring? `({ id, option = true, name = 'unnamed' }) => // ...` replaces ``` function(userObject) { const id = userObject.id; const option = userObject.option || true; const name = userObject.name || 'unnamed'; // ... } ``` I think this comparison speaks for itself. In pre-es6 code bases you TONS of code that looks like the second.