Error Object - Javascript DOM

Javascript examples for DOM:Error

Error Object Properties

Property Description
name Sets or returns an error name
message Sets or returns an error message (a string)

Return the error name and a description of the error:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo" style="color:red"></p>

<script>
try {/*from   w ww.j a  v a  2  s .c  om*/
    methodDoesNotExist("Welcome guest!");
}
catch(err) {
    document.getElementById("demo").innerHTML =
    err.name + "<br>" + err.message;
}
</script>

</body>
</html>

Related Tutorials