1

Here i have a question regarding Double parentheses, can anyone please explain me how does it works.

function counter() {
  console.log("hI");
  return function (){
    console.log("inside hI");
  }
}    
counter()();
OliverRadini
  • 6,238
  • 1
  • 21
  • 46

1 Answers1

1

In your example counter returns a function, so having parentheses after the call to counter calls the function that counter returns

OliverRadini
  • 6,238
  • 1
  • 21
  • 46