Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

insert condition in a object javascript

const arr = [
  ...(isConditionTrue() ? [{
    key: 'value'
  }] : [])
];

const obj = {
  ...(isConditionTrue() ? {key: 'value'} : {})
};
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #insert #condition #object #javascript
ADD COMMENT
Topic
Name
3+9 =