Hi,

If the function is expected as a property of some object (including
`window`), then I'd probably do this:

    if (typeof obj.functionName == 'function')

So for instance:

    if (typeof window.globalEval == 'function')

If you need to check whether a function is defined in the current
scope and not on a property (so, on the current variable object or one
of the others in the scope chain), I'd probably be a bit more
defensive:

    var defined = false;
    try {
        defined = typeof functionName == 'function';
    }
    catch (e) {
    }

Prototype also adds a function to `Object` that does the check:

    if (Object.isFunction(window.globalEval))

...which is just a shorthand way of doing the typeof.

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Feb 4, 3:14 pm, RK <rajkishore.puj...@gmail.com> wrote:
> How would you check if a function is defined using prototype
>
> Thanks,
> RK.

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to