Is possible to deconstruct when using an anonymous function as a parameter.
For example (no real code):
With this common code:
// Common code.
const objectXX = {
a: {x: "ax", y: "ay"},
b: {x: "bx", y: "by"},
}
const printableXY = (x, y) => `(${x},${y})`
And this working code:
// Working code
const xyValues = Object.entries(objectXX).map(entry => {
const [_, v] = entry
return printableXY(v.x, v.y);
})
I want to refactor to use deconstructor in the map parameters and creating the anonymous function.
Is not possible to do something like these not working examples:
const xyValues = Object.entries(objectXX)
.map(const [_, v] => printableXY(v.x, v.y));
const xyValues = Object.entries(objectXX)
.map(const [_, [x, y]] => printableXY(x, y));
// Or even this one
const xyValues = Object.entries(objectXX)
.map([_, [x, y]] => printableXY(x, y));