How to use spread operator in Javascript filter some properties in an object

Supakon_k
Jan 22, 2022
Photo by Claudio Schwarz on Unsplash

Do you know what the spread operator is, the spread operator looks like this ‘…’ this three-dot is called spread operator.

so, I will show you how to use the spread operator to filter some properties in an object.

First, we have a duck object like this picture that has four properties “color, eye, leg, ball”

I don’t want “ball” property in my duck object, so I can use spread operator to filter the ball out like this picture

then, we will get a new object “duckWithoutBall”. yeah, you can do it.

here is an example code

thank you for reading and enjoy your coding.

--

--