Answers for "insert condition in a object javascript"

35

insert condition in a object javascript

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

insert condition in a object javascript

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

insert condition in a object javascript

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

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

Code answers related to "insert condition in a object javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language