I have a function that looks like this:
function MyFunction() {
//do some work
if (SomeCondition === true) {
//do some work
FunctionToCall();
}
//do some more work
}
function FunctionToCall() {...}
If ever I call the FunctionToCall(), I don’t want to continue with do some more work. Do I need to put a return true or return false statement after the FunctionToCall(); statement? It seems to work with both.
Thanks.
As you said, you would need to put a
returnafter the call toFunctionToCall. By the sound of it, it doesn’t matter what you return (this will returnundefined):If you did care about the result of
FunctionToCall, you could return the value returned from that:Alternatively, you could use an
else, and not bother with areturnstatement (this will returnundefinedtoo):