Skip to content

Instantly share code, notes, and snippets.

@rainyjune
Created November 3, 2012 09:15
Show Gist options
  • Save rainyjune/4006685 to your computer and use it in GitHub Desktop.
Save rainyjune/4006685 to your computer and use it in GitHub Desktop.
JavaScript Try Catch
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Chrome Developer Tools</title>
</head>
<body>
<a href="#" id="c">click</a>
<script type="text/javascript">
function t(x){
if(x<10){
throw new Error('bad parameter');
}
return x*x;
}
try{
t(3);
}
catch(e){
alert(e.stack);
}
alert('uu');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment