Let's say I have function below
var isallow = false; function checkToAllow(){ if(isallow == false) // stop execution of calling method( parent method) } function showMEVal(){ checkToAllow(); console.log("I am here because I am allowed"); } so basicaly, showMEVal() method will first check that execution further is allowed or not, if it is allowed it will continue further, else it will exit.
This is to be common functionality to a number a function where it needs to be first checked whether it should be continue or not.
I dont want to explicitly work with returned values from checkToAllow() method, like
function showMEVal(){ if(checkToAllow() == true) console.log("I am here because I am allowed"); } I was thinking to use event.stopImmediatePropagation(); but it does not seems it will work.
Please advise
Thanks
function showMEVal() { if (!checkToAllow()) return; console.log("I am here because I am allowed"); }