not add the property in obj if it is undefined javascript code example
Example 1: js conditional object property
const a = {
...(someCondition && {b: 5})
}
Example 2: conditionally add property to object ts
const a = {
...(someCondition && {b: 5})
}