Last active
August 29, 2015 14:01
-
-
Save dreamyguy/c804d6cc61458de877c2 to your computer and use it in GitHub Desktop.
Check if function exists, through the console.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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