I am trying to create a property for my object based on data retrieved from backend, but only if it exists.
const newItem = {
isProtected = items.hasOwnProperty('PATHID') ? items['PATHID'] : undefined
}
In case, items does not contain the property PATHID, I wish not to create "isProtected" property. I can't figure it out if it's possible, instead I use "undefined" or "null" value.
Is there any way to not create property if it does not fulfill the assigned condition?