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

Popular posts from this blog

php - Wordpress: Link a post to posts of another category manually -

delphi xe7 upload/download dropbox file using the rest client and show progress -

java - Get more than One value and display it -