how to add object key on condition in js code example
Example 1: js conditional object property
const a = {
...(someCondition && {b: 5})
}
Example 2: js conditional object key
const object = {
...bool && { foo: 2 },
}
const a = {
...(someCondition && {b: 5})
}
const object = {
...bool && { foo: 2 },
}