JavaScript/Reserved words/catch
< JavaScript | Reserved words
(Redirected from JavaScript/Reserved Words/catch)The catch keyword
[edit | edit source]The catch keyword is used as part of the try statement.
Examples
[edit | edit source]![](http://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Crystal_Clear_action_apply.png/20px-Crystal_Clear_action_apply.png)
try {
log(-12.05);
alert("Executed comment successfully.");
} catch(err) {
document.getElementById("demo").innerHTML = err.message;
}
</script>
(Will add to the HTML element called "demo" the error message.)