3 ms·
Converting a string to a number throws an exception because either you are sure it's a number and an exception is an elegant way for your program to die in case
by HelloNurse 9y ago
Converting a string to a number throws an exception because either you are sure it's a number and an exception is an elegant way for your program to die in case there's a bug or an exceptional condition; or you aren't sure and you need to validate the input and deal with bad inputs on your own before attempting the conversion.