Created
April 19, 2020 15:35
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
@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.
@awvalenti re https://stackoverflow.com/q/61467793 see above.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mepley re https://stackoverflow.com/questions/61298632/is-it-possible-to-destructure-some-properties-and-also-assign-pass-the-entire-ob see above and https://stackoverflow.com/questions/47117312/arrow-functions-destructuring-arguments-and-grabbing-them-as-a-whole-at-the-sam/47117585