Skip to content

Instantly share code, notes, and snippets.

@icio
Created January 30, 2011 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icio/802351 to your computer and use it in GitHub Desktop.
Save icio/802351 to your computer and use it in GitHub Desktop.
function bad (foo) {
if ( ! (foo instanceof Bar) ) {
throw new TypeError("This is an annoying restriction!");
}
return foo.baz(foo.quux(10));
}
function good (foo) {
if ( !foo.baz || !foo.quux ) {
throw new TypeError("We need foo to have baz and quux methods.");
}
return foo.baz(foo.quux(10));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment