Skip to content

Instantly share code, notes, and snippets.

@dreamyguy
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dreamyguy/c804d6cc61458de877c2 to your computer and use it in GitHub Desktop.
Save dreamyguy/c804d6cc61458de877c2 to your computer and use it in GitHub Desktop.
Check if function exists, through the console.
// a loose check, to see if object exists
if (something) {
console.log('%c something() is present! ', 'background: #bada55; color: black');
} else {
console.log('%c something() is NOT present! ', 'background: #de1e7e; color: white');
}
// a strict check, object must be a function
if (typeof(something) === 'function') {
console.log('%c something() is present! ', 'background: #bada55; color: black');
} else {
console.log('%c something() is NOT present! ', 'background: #de1e7e; color: white');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment