Answers for "add object by condition in javascript"

2

insert condition in a object javascript

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

const obj = {
  ...(isConditionTrue() ? {key: 'value'} : {})
};
Posted by: Guest on January-04-2021
1

insert condition in a object javascript

const a = {
   ...(someCondition? {b: 5}: {} )
}
Posted by: Guest on January-04-2021

Code answers related to "add object by condition in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language