Dan G. Switzer, II schrieb:
Shelane,
Is there a test to know if a function has been defined or declared?
function modify(){
...my code
}
if(function('modify'))
or something like that?
A function is just a variable.
if( !!modify ) alert("exists");
if( typeof modify == "function" ) alert("exists and is a function");
These are just a few methods of testing.
Safest way to test for global variables is this:
if ( window.myVariableToTestFor ) {
// its there!
}
I've experienced quite a lot cases where checking for a global variable
that didn't exists without specifying window as the property's object
threw ugly errors.
--
Jörn Zaefferer
http://bassistance.de