javascript set object value if defined code example
Example: js set value in object only if defined
const value = getValue()
const destination = {
...(value ? { value } : {})
}
const value = getValue()
const destination = {
...(value ? { value } : {})
}