'What is the reason/benefit for writing short circuit conditional?
I was searching a lot about short circuit, but I have a big doubt with this code.
const getClient = (userInfoContext) => {
const context = userInfoContext && userInfoContext.get()
const payload = context && context.payload && context.payload['www.payload.com']
return payload && payload.clientId
}
I want to know what is the benefit of write the code like that instead of:
const getClient = (userInfoContext) => {
const context = userInfoContext.get()
const payload = context.payload['www.payload.com']
return payload.clientId
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
