0
Error handling any one can explain me this code
// Pretend this is coming from a server as response let a = "Harry bhai"; a = undefined; if (a !=undefined) { throw new Error('This is not undefined'); } else { console.log('This is undefined'); }
1 Answer
+ 2
If a is not undefind, JS crash with the error ('this is not undefined')
If you don't want program crash, surround the block with try/catch