Answers for "add key to object only when there is value"

0

add key to object only when there is value

const buildAnObjectFromAQuery = query => ({  ...query.foo && { foo: query.foo },  ...query.bar && { bar: query.bar },});
Posted by: Guest on June-21-2021

Code answers related to "add key to object only when there is value"

Browse Popular Code Answers by Language