Answers for "js adding item in objet on condition"

2

insert condition in a object javascript

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

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

insert condition in a object javascript

const a = {
   ...(someCondition && {b: 5})
}
Posted by: Guest on October-22-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language