add condition based object with object assign code example Example: js conditional object property const a = { ...(someCondition && {b: 5}) }