In php I\'m writing the following
In javascript I wish to test if the
Use a function expression, not a function declaration.
if(typeof myfunction != 'function'){ window.myfunction = function(){}; }
(I'm using window since your last paragraph suggests you want a global function)
window