Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Throwing Specific Error Type</title> </head> <body> <script> var num = prompt("Please enter a number"); try { if(num != "" && num !== null && isFinite(+num)) { document.write(Math.exp(num)); } else { throw new TypeError("You have not entered a number."); } } catch(e) { document.write(e.name + ": " + e.message); } </script> <p><strong>Note:</strong> The <code>Math.exp(x)</code> method returns a number representing <code>e<sup>x</sup></code>, where <code>e</code> is Euler's number and <code>x</code> is the argument.</p> </body> </html>