There is an external js which I call in to the main page. This external file has a function
function fruitLib(){
//do stuff
}
I have another external js and there is another function.
function price(){
//do stuff
}
Now how can I check if fruitLib() exists before calling price()? Below is what I tried but doesn't work (maybe because both files are external files).
if (typeof fruitLib== 'function') {
price();
}
fruitLibis a global function. Can you provide more information?functionAinone.jsand I want to callfunctionoftwo.jsonly iffunctionAis available.price()is in the main html file, is it possible to check iffruitLib()is available?fruitLibis a global, and it will work iffruitLibis a variable you've received a function reference into. The question makes no sense at present.