javascript - Any way to raise an error when getting the function instead of running it -
a common error:
a = myfunction;
...instead of:
a = myfunction();
any way avoid this?
in case have function inside object, object avoid return functions , require execution?
you can use typeof
check if it's function:
a = myfunction; var result; if (typeof == "function") // set myfunction, not myfunction() result = a(); else // presumably set myfunction() , not myfunction result = a;
this way can call function if indeed function, otherwise can else it, assuming that's you're wanting do.
Comments
Post a Comment