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();
}