Skip to content

Instantly share code, notes, and snippets.

@radamant
Created January 22, 2010 00:57
Show Gist options
  • Select an option

  • Save radamant/283385 to your computer and use it in GitHub Desktop.

Select an option

Save radamant/283385 to your computer and use it in GitHub Desktop.
var add = function (a, b) {
if (typeof a ! == ' number' | | typeof b ! == ' number' ) {
throw {
name: ' TypeError' ,
message: ' add needs numbers'
};
}
return a + b;
}
try{
add("foo");
} catch(e){
// handle exception
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment