Javascript check if function exists => http://fitingsute.nnmcloud.ru/d?s=YToyOntzOjc6InJlZmVyZXIiO3M6MjE6Imh0dHA6Ly9iaXRiaW4uaXQyX2RsLyI7czozOiJrZXkiO3M6MzU6IkphdmFzY3JpcHQgY2hlY2sgaWYgZnVuY3Rpb24gZXhpc3RzIjt9 I prefer to use a cautious trigger class to handle this so I can easily define an on event to fire when we need to respond to the alternate code path. You can see that once the classes are defined the actual error handler and function call are terse, while the cautious state handling is set in a reusable class. Using JavaScript In order to check if a function exists using plain JavaScript, use the following code: The output is the following: Using jQuery jQuery contains the which finds out if the parameter passed to it is a function. See the code comments for usage. You can use the in operator, the typeof operator, or finally, the automatic typecasting of undefined to false. You can always check e for the exact error with e. This post shows how to check if a function exists, before calling it. You can see that once the classes are defined the actual error handler and function call are terse, while the cautious state handling is set in a reusable class. The difference is too slight to warrant forking the file into different versions. There are several ways to do this. Will you give this article a +1? I know many people that like to add those two functions because of how useful they are including me , and it is trivial to choose this method for determining if someone else has done such a thing. It makes sense on one page the dependency is there but not another. He is the Editor of a Developer Magazine called. So say, for example, you have a homepage slider using flexslider or something similar. Determining the existence of a variable - Will you give this article a +1? When using scripts that are shared between different areas of a site, there may javascript check if function exists cases where a function is called that doesn't exist. It makes sense on one page the dependency is there but not another. The difference is too slight to warrant forking the file into different versions. If you know javascript check if function exists have a condition in a game or an asynchronous communication delay, where the user is allowed to check progress or what not, you plan for it and utilize a try-catch. I prefer to use a cautious trigger class to handle this so I can easily define an on event to fire when we need to respond to the alternate code path. You can always check e for the exact error with e. You can see that once the classes are defined the actual error handler and function call are terse, while the cautious state handling is set in a reusable class. See the code comments for usage. If you do not define your own onError event, it will fire as a classic alert and not bring down your page. Hold your horses, we're doing something awesome. I know many people that like to add those two functions because of how useful they are including meand it is trivial to choose this method for determining if someone else has done such a thing. People say not to extend the default objects like this in case they get updated in the future but this method would protect against that issue anyway. So say, for example, you have a homepage slider using flexslider or something similar. Some of the other methods in this comment thread would work too.