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 8411201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:22:51+00:00 2026-06-10T00:22:51+00:00

Leave a comment if I’m wrong: In my memory, I thought the difference between

  • 0

Leave a comment if I’m wrong: In my memory, I thought the difference between the two style of function creation:

function myFunc(){};

and

myFunc = function(){};

is the first evaluate right away, and the later waits for the function call.

so I got this code in this article about global variable is attach to window object:

function setGloabalVariable(){
  window.variable = '1';
}

after loading the page, why the variable still undefined?

  • 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-06-10T00:22:51+00:00Added an answer on June 10, 2026 at 12:22 am

    The difference between these two types of declarations is that the first is a named function statement, the second is an anonymous function expression. Neither of them is automatically executed at their point of declaration (you may be thinking of an IIFE).

    // Create a symbol named "my_named_function"
    // that points at the named function "my_named_function"
    function my_named_function() {
    }
    
    // Create a symbol named "my_anonymous_func"
    // that points to the *unnamed* function <anonymous function>
    var my_anonymous_func = function() {
    }
    

    Both my_named_function and my_anonymous_func are unexecuted. Both may be executed by calling them:

    my_named_function();
    my_anonymous_func();
    

    An IIFE (Immediately Executed Function Expression) works a little differently:

    (/* define a function */ function() {
    
    })(/* and *immediately* execute it */);
    

    I recommend reading through kangax’s excellent article on function expressions and statements for more information on this subject.

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

Sidebar

Related Questions

In a leave application form, there are two time fields 'From' and 'To'. When
I was wondering if name in the leave comment template can be separated to
At the wordpress form, when you leave comment as guest, there's a website field
AGAIN: If you're voting -1, please leave a comment explaining why. This post isn't
I have a form in my page for users to leave a comment. I'm
I have a Django application with two models: the first one is django.contrib.auth.User and
Is it possible to leave a ContextMenuStrip open after a selection/check of certain items?
I have to leave in a DataTable only records with dates currently not present
I am developing a Leave of Absence Request Form for a client. The form
I need to proxy a feed and leave most of the nodes unspoiled and

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.