Esta página contém um exemplo do try-catch tipico do JavaScript
<script>
try {
var x = 1 / 0;
//myroutine(); // may throw three types of exceptions
}
catch (e) {
if (e instanceof TypeError) {
Alert("TypeError");
} else if (e instanceof RangeError) {
alert("RangeError");
} else if (e instanceof EvalError) {
alert("EvalError");
}
else {
// statements to handle any unspecified exceptions
logMyErrors(e); // pass exception object to error handler
}
}
</script>>