Skip to content

Instantly share code, notes, and snippets.



Created Jan 30, 2011
What would you like to do?
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