In php I'm writing the following
<?php
if(x != 0) {
echo "function myfunction(){};";
}
?>
In javascript I wish to test if the function exists and if not write out an empty function
if(typeof myfunction != 'function'){
function myfunction(){};
}
This works great in firefox but, in chrome even if the typeof equals function it still goes into and creates the empty function. I can't find a work around for chrome, i've tried if(!myfunction), if(typeof window.myfunction != 'function) but nothing seems to work here for chrome when everything seems to work in firefox. Any ideas?