What is the way you always use to prevent error when data is null or undefined?
For my case, I always face this when 'initVar' is null or undefined. Or at lease 'aaa' is null or undefined.
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
What is the way you always use to prevent error when data is null or undefined?
For my case, I always face this when 'initVar' is null or undefined. Or at lease 'aaa' is null or undefined.
const {aaa: {bbb, ccc}} = initVar
So that example is desrructhring assignment. I look at that in a different post which is linked at the bottom of this one.
Maybe you could actually use the spread to start with default values and override with
initVar
:But not sure if that is really useful in maybe more complex deconstructions? :D