JavaScript Error name Property

Introduction

The name property sets or gets the name of an error.

The following code has a wrong function name.

View in separate window

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

<script>
try {/*w  w w. j  av  a2s  .c  om*/
  notExistFunction("Welcome guest!");
}
catch(err) {
  document.getElementById("demo").innerHTML = err.name;
}
</script>

</body>
</html>



PreviousNext

Related