Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6326167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:02:20+00:00 2026-05-24T17:02:20+00:00

When answering another question, I was using this pattern to call a function recursively:

  • 0

When answering another question, I was using this pattern to call a function recursively:

(function() {
    // ...
    if(should_call_again) arguments.callee();
})();

which worked. I got feedback that naming the function also worked:

(function func() {
    // ...
    if(should_call_again) func();
})();

However, with this technique, window.func is undefined, which came as a surprise to me.

If I put it simply, my question is: why is the following true?

function a() {}
typeof window.a; // "function"

(function b() {})
typeof window.b; // "undefined"

b is still be accessible inside b itself. So it seems like the ( ) create another scope, but that cannot be the case because only functions create another scope, and I’m just wrapping it inside ( ).

So why does wrapping a function inside ( ) not put the function into the global object?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:02:21+00:00Added an answer on May 24, 2026 at 5:02 pm

    Because you’re not writing a function declaration, but a function expression.

    Functions defined in function expressions only get stored someplace when you assign them to a variable; you did not do that; you just called it immediately.


    In a [very loose!] sense, you could think of function declarations as a special form of function expression assignment:

    function a() {}
    // vs:
    var a = function() {};
    

    This is still not a strictly accurate comparison, but it may help in understanding that a function declaration is kind of a special thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, in answering another question on this site, I wrote a class for someone
I'm actually answering my own question here. I must be the only person in
I recently had this question in an interview to write test cases to test
(self asking and self-answering because I spent hours on the web looking for this,
Thank you guys answering my previous problem on undefined reference to function . As
So I have seen some other posts similar, but not quite answering what I
I used a modified version of the code here Determining what classes are defined
My HTML <div class=questions> <p>Q1</p> <label><input name=q1 id=q1-a type=radio />Q1 ans A</label> <label><input name=q1
I am not new to java and C#. I thought I understand the concept
I'd like to make sure that after editing and then navigating away from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.