DEV Community 👩‍💻👨‍💻

Discussion on: You don't need classes

nitsanavni profile image
Nitsan Avni

in this function:

const moveShape = ({ x, y }) => shape => ({ ...shape, x, y });
Enter fullscreen mode Exit fullscreen mode

why do we provide { x, y } first and then shape, and not the other way around?

rommguy profile image
Guy Romm

Because the common use of such functions is to use the curried result as an argument to another function

So you would do this -
const moveByFive = moveShape({x: 5, y: 5})

Then you would do some operations on a shape or a collection of shapes

filter(shape => shape.x < 10),

lukeshiru profile image
Luke Shiru Author

Thanks a lot @rommguy for taking the time to explain that. Great explanation btw! :D

Some comments have been hidden by the post's author - find out more