Check if a Javascript function exists

by Jon Hibbins on 22 March 2009
Filed under: Code, Javascript, Quick Tips

If you want to check if a Javascript function exists before you attempt to call it and get an error try:

// Check if a Javascript function exists and run it if it does
if(typeof window.Function == 'function') {
    Function();
}

One Response to “Check if a Javascript function exists”

  1. JamesD Says:

    Thanks for the useful info. It’s so interesting

Leave a Reply