Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

conditionally add property to JSON object javascript es6

const buildAnObjectFromAQuery = query => ({
  ...query.foo && { foo: query.foo },
  ...query.bar && { bar: query.bar },
});
Source by medium.com #
 
PREVIOUS NEXT
Tagged: #conditionally #add #property #JSON #object #javascript
ADD COMMENT
Topic
Name
4+9 =