JavaScript Error name Property - TypeError: A type error has occurred - Javascript DOM

Javascript examples for DOM:Error

Description

JavaScript Error name Property - TypeError: A type error has occurred

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Errors</h1>

<p>You cannot convert a number to upper case:</p>

<p id="demo"></p>

<script>
var num = 1;//ww w .  j  ava2 s.  c  o  m
try {
    num.toUpperCase();
}
catch(err) {
    document.getElementById("demo").innerHTML = err.name;
}
</script>

</body>
</html>

Related Tutorials