Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to check if function exists or not in Javascript and jQuery

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.98k
    Comment on it

    There might be some cases when we need to call a function without checking if function's definition is loaded or not. If loaded then that will be fine but if not loaded then it will throw an error as undefined function. We can handle this in Javascript:

    if (typeof functionName == 'function') {
    
         functionName();
    
    }

     

     

    In Jquery:

    if ($.isFunction(functionName)) {
    
        functionName();
    
    }

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: