Is there a way of exiting a function that has called the function that's currently executing?
An example would be:
function doOneTwoThree(){
doStuff(1, print);
doStuff(2, print);
doStuff(3, print);
}
function doStuff(parameter, aFunction){
if(parameter === 2) {
//exit from doOneTwoThree
}
aFunction(parameter);
}
function print(something){
console.log(something);
}
Another option would be to return an error in doStuff and check for that error in doOneTwoThree every time I call doStuff. But i would like not to have to check for it every time...
returnwould return to the calling function, though? Or am I misunderstanding?