Get Programming with JavaScript - Listing 7.14

Listing 7.14 - Renaming properties when object destructuring

const move = ({x, y}, {x: dx, y: dy}) => ({x: x + dx, y: y + dy}); const showPoint = ({x, y}) => console.log(`( ${x} , ${y} )`); const point1 = { x : 2, y : 5 }; const point2 = move(point1, { x : 4, y : -2 }); showPoint(point1); console.log("Move 4 across and 2 down"); showPoint(point2);