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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:58:17+00:00 2026-05-23T22:58:17+00:00

Sorry, that title probably doesn’t make much sense, but what I want to know

  • 0

Sorry, that title probably doesn’t make much sense, but what I want to know is the difference between:

window.myfunc = function(){}

and

function myfunc(){}

With jsfiddle, the functions only seem to work when attached to window. I’m assuming this is something to do with how it’s set up to read the javascript and html separately, but that there is otherwise no difference?

  • 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-23T22:58:18+00:00Added an answer on May 23, 2026 at 10:58 pm

    The first one garanties you the function is global and will available everywhere.

    The second one does the same. but the second one will take the scope of the first function that embed it.

    first case:

    function foo()  {
       window.bar = function (){}
    }
    foo();
    bar(); // is valid;
    

    second case

    function foo()  {
        function bar(){}
    }
    foo();
    bar(); // will fail
    

    i hope this makes sense now to you

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

Sidebar

Related Questions

Sorry if that title doesn't make sense, I'm new to Rails and I'm building
Sorry if the title is not that specific, but I don't know how else
Sorry for the weird title, but well, that's exactly what I need. I know
Ok, so that title probably doesn't explain my question well. Hopefully this makes sense.
Sorry that I haven't done much of my own research but I do not
Sorry that I can't find the answer through google - But I know this
sorry if that's a dumb title, i don't know how to express this clearly
I know that the title might seem silly, couldn't think of something better, sorry.
Sorry if the title is not too descriptive, but I didn't know how to
Using MS Access. I'm sorry that the title is vague--i just don't exactly know

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.