0

I have been utilising ? a lot recently when writing object key:value pairs e.g:

const myData = {
    name: data.hasValue?.name
}

However I have some instances where I can't use ? to check for definition. For example when interrogating a node on data directly:

const myData = {
    name: data.hasValue?.name,
    colour: data.colour
}

What is the quickest and simplest way to simply not include colour when creating myData if data.colour is undefined? If I leave it like above, then I get color: undefined but I would prefer color to just not be a value on the object at all.

user1486133
  • 1,309
  • 3
  • 19
  • 37

0 Answers0