Day #10 Pro Tip #Javascript

Conditionally set an object property using the spread operator !!

Arwa Lokhandwala
Geekabyte
1 min readApr 11, 2018

--

Let’s consider this example:

In the above object, we want to add publications property only if the writer value is true, this can be achieved in the following ways

OR

I found this really amazing !!

Thanks for reading

Stay tuned for more updates !!!

--

--