JavaScript Error name Property ReferenceError

Introduction

ReferenceError: An illegal reference has occurred

You cannot use the value of a non-existing variable.

View in separate window

<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>

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

</body>
</html>



PreviousNext

Related