{ Dev Farm }

Web & Windows Development

How to check if a Javascript Function Exists or Is Defined

| 0 commenti

To check if a function exists before you try and call it (and get a nasty javasscript error), use typeof to check.

Heres a sample:

if(typeof helloWorld == 'function') {
    // function exists, so we can now call it
    helloWorld();
}

Lascia un commento

I campi obbligatori sono contrassegnati con *.