How to check if a javascript function exists or is defined?
To check if a Javascript function exists before calling it, try this:
1 |
if(typeof functionName == 'function') |
If you want to reduce the number of strings hanging around in your code, try this instead
1 |
if (typeof(possibleFunction) == typeof(Function)) |
Leave a Reply