JavaScript Error message Property

Introduction

The message property sets or gets an error message.

Return an error message.

The following code has a wrong function name.

View in separate window

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

<script>
try {/*from w  w w .  ja  va  2s . co m*/
  notExistFunction("Welcome guest!");
}
catch(err) {
  document.getElementById("demo").innerHTML = err.message;
}
</script>

</body>
</html>

The message property returns a String representing a description of an error.




PreviousNext

Related