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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:44:16+00:00 2026-05-31T19:44:16+00:00

So the have seem something like this today: $$(‘input’).each(function() { // do something });

  • 0

So the have seem something like this today:

$$('input').each(function() {
 // do something
});

What is the difference between that and this:

$$('input').each( // do something );

The private function on the first example is within that for loop scope, so it is not reference-able anywhere else, so what would the benefit of having it?

  • 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-31T19:44:17+00:00Added an answer on May 31, 2026 at 7:44 pm

    The anonymous function knows its current scope and variables.

    function a() {
       var foo = 'test';
       $('something').each(function() {
          alert(foo);
       })
    }
    

    This function would alert ‘test’ because foo is defined within its scope.

    function a() {
       var foo = 'test';
       $('something').each(b)
    }
    
    function b() {
       alert(foo);
    }
    

    This function would cause a javascript error stating that the variable foo is undefined.

    If you need to define a function that only makes sense within an exact scope and don’t want to throw lots of variables around or recalculate a lot of things, it’s more comfortable to define an anonymous function.

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

Sidebar

Related Questions

I have a SQL*Loader control file that has a line something like this: FIELDS
I seem to have missed something - in this step through it talks through
I seem to have a curious problem. I set up OpenGL like this: glViewport(0,
I'm dealing with someone else's code here and have come across something like this:
I have something like this: enum EFood{ eMeat, eFruit }; class Food{ }; class
I am trying to draw a figure something like this: I need to have
I have asimple WCF HTTP/SOAP web service, the service implementation looks something like this:
I have a class like this that I want to save in ViewState for
If I have a piece of code which does something like this. try {
I've seem to have hit a bug or i have overlooked something. I written

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.