[SOLVED] Javascript, execute function


I have next function

  var hideAll = function() {
    // code  
    return ///...  

And I am using this function like callback in another function.
When I am using it like

function (params, hideAll) {}  

all working well, but when I am using

function (params, hideAll() ) {}    

all not working well!

So my question is, what is difference between hideAll and hideAll() function executions?


hideAll – this is a reference to the function
hideAll() – this is execution of the function, its result

function (params, hideAll) {} is a correct function definition,
whereas function (params, hideAll() ) {} is not – you are unable to call another function in function definition.

However you could still write the following valid code:

  var hideAll = function() {
    // code  
    return ///...  

  var functionWithCallback = function(callback){
  var closureReferringHideAll = function(){

  // The following two lines will do exactly the same in current context,
  // i.e. execute hideAll.

Answered By – Li0liQ

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *