DEV Community

Discussion on: Set Variable As A Key Name In JavaScript Object

Collapse
 
capscode profile image
capscode

I said in Production application... its useful.
When the same scenario comes in React JS its pretty much helpful and easy if you use spread operator

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

That was not your claim though; of course spreading into a new object has many uses, but saying it is the "best" way is plainly wrong. It's not. In fact, in many cases, it is objectively worse than the alternative of directly setting the key.