My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

How the recursion is working in the following code?

Bhojendra Rauniyar's photo
Bhojendra Rauniyar
·Feb 19, 2019

Can anyone please explain this code?

(function f(){
  function f(){ return 1; }
  return f();
  function f(){ return 2; }
})();

I really didn't understand the recursion. I thought it will return 1 because it already returned f(), but it returned 2.