const arr = [ ...(isConditionTrue() ? [{ key: 'value' }] : []) ]; const obj = { ...(isConditionTrue() ? {key: 'value'} : {}) };
const a = { ...(someCondition? {b: 5}: {} ) }