JavaScript Error name Property - SyntaxError, A syntax error has occurred - Javascript DOM

Javascript examples for DOM:Error

Description

JavaScript Error name Property - SyntaxError, A syntax error has occurred

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Errors</h1>

<p>You cannot evaluate code that contains a syntax error:</p>

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

<script>
try {/* w  w  w.j a v a 2 s.c o m*/
    eval("console.log('Hello)");
}
catch(err) {
    document.getElementById("demo").innerHTML = err.name;
}
</script>

</body>
</html>

Related Tutorials