First of all, return not a function, you can just do this:
return true;
Now, only to execute myFunction , if check returns true , you can do this:
check() && myFunction()
This is a shorthand for:
if(check()){ myFunction(); }
You do not need to compare the return value of check with true . This is a logical value.
Now, instead of myFunction() you can have any JavaScript code in this if . If you really want to use, for example, myFunction , you have to make sure that you define it somewhere, first:
function myFunction() {
source share