Check if a Javascript Function Exists or Is Defined

To check if a Javascript function exists before calling it, try this:

if (typeof yourFunctionName == "function") {
    yourFunctionName();
}

Source:

http://www.idealog.us/2007/02/check_if_a_java.html

2 thoughts on “Check if a Javascript Function Exists or Is Defined

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Captcha Captcha Reload

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>