I’ve a set of jquery and generally javascript function in a js. Now I want to avoid some of the functions to be available on some condition. For example:
function test () {
alert("hi");
}
function avoid () {
if(condition) {
//here avoid to call test
}
}
Thanks
If you want to remove a function without errors (provided the caller of the function doesn’t expect a returned result), you might do
Note that if your
avoidfunction is in a different scope, you might have to adapt. For example iftestis defined in the global scope, then you’d dowindow.test = function(){};