I am trying to check if the key exists in the nesting level to avoid the error
data={
payment-term
:{
description
:xyz description
}
}
how I am fetching data[payment-term
].description
It works well with the above set of data but gets error on the below set of data
data={
payment-term
: null
}
so in order to avoid the error, I am using optional chaining but am not able to write due to I have a special character in the key
let description= data?[payment-term
]?.description
getting error on the above statement
Can anybody help me to write the statement in the correct way?