javascript try catch error, not printing defined error. what's happening here. and why NaN printing.
let num = "sflkj"
try {
let thenum = parseInt(num)
console.log(thenum)
} catch (error) {
console.log("that is not a number.")
}
Just like the anwser above says NaN is the value parseInt returns, NaN is an abbreviation to Not a Number. It's not an error to go to catch block.
parseInt function does not throw an error and always returns something. if it was not possible to parse the number, then NaN will be returned