2021年2月5日星期五

Difference between sending a function name as a parameter vs explicitly identifying it as a function

Sorry if the title isn't clear but I don't know the correct terminology, so basically what is the difference between this:

doSomething(servletPath,      function () {          checkErrors();      }, function () {          init();      }, function () {          showErrorMsj();      }  );  

And this:

doSomething(servletPath, checkErrors, init, showErrorMsj);

Both seem to work the same on an old legacy project I am maintaining but I would like to know if one is preferred to the other and why.

https://stackoverflow.com/questions/66073191/difference-between-sending-a-function-name-as-a-parameter-vs-explicitly-identify February 06, 2021 at 11:02AM

没有评论:

发表评论