JavaScript Error name Property - ReferenceError, An illegal reference has occurred - Javascript DOM

Javascript examples for DOM:Error

Description

JavaScript Error name Property - ReferenceError, An illegal reference has occurred

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Errors</h1>

<p>You cannot use the value of a non-existing variable:</p>

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

<script>
var x;/*  w ww  . ja v  a  2s . c o m*/
try {
    x = y + 1;
}
catch(err) {
    document.getElementById("demo").innerHTML = err.name;
}
</script>

</body>
</html>

Related Tutorials