Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

conditional json spread operator

const buildAnObjectFromAQuery = query => ({
  ...query.foo && { foo: query.foo },
  ...query.bar && { bar: query.bar },
});
Source by medium.com #
 
PREVIOUS NEXT
Tagged: #conditional #json #spread #operator
ADD COMMENT
Topic
Name
1+1 =