0

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
  • 5,157
  • 13
  • 37

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
  • 5,157
  • 13
  • 37