Skip to content

Instantly share code, notes, and snippets.

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 guest271314/aaaed8ca4906ea7b348524d555d0e2b4 to your computer and use it in GitHub Desktop.
Save guest271314/aaaed8ca4906ea7b348524d555d0e2b4 to your computer and use it in GitHub Desktop.
Is it possible to destructure some properties and also assign/pass the entire object within a single assignment expression of a map callback function?
// https://stackoverflow.com/q/61298632
let o = [{firstname:0, lastname:1}, {firstname:2, lastname:3}];
const handleMapCallback = (person, _, __, {lastname, firstname} = person) => {
console.log(person, lastname, firstname);
};
o.map(handleMapCallback);
@guest271314
Copy link
Author

@madigan re https://stackoverflow.com/questions/61419799/can-you-reference-a-destructured-function-parameter-in-javascript

Is there a way to do this without a wrapper object?

Same number of characters setting default parameter from destructuring one or more previously defined parameters.

@guest271314
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment