Skip to content

Instantly share code, notes, and snippets.

@whitelizard
Last active September 26, 2021 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whitelizard/c9a902df62e0c61bc8300cf66bec693c to your computer and use it in GitHub Desktop.
Save whitelizard/c9a902df62e0c61bc8300cf66bec693c to your computer and use it in GitHub Desktop.
Destructuring in multiple steps
const func = (params = {}, data = {}) => {
const {
fallbackMessage: msg = 'Unknown',
offset = 4,
pos = {},
...options
} = params;
const { x = 0, y = 0 } = pos;
const { title = '', items = [] } = data;
const [head, ...tail] = items;
// some nice logic
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment