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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:38:41+00:00 2026-05-27T04:38:41+00:00

Wrox Profesionnal Javascript p188 I don’t understand this part at line 8 where the

  • 0

Wrox Profesionnal Javascript p188
I don’t understand this part at line 8 where the anonymous function already have an argument of num, but how can (i) is copied into the argument num. Normally a function would stop at the closing bracket }, adding (i) doesn’t make sense for me.

function createFunctions(){
    var result = new Array();
    for (var i=0; i < 10; i++){
       result[i] = function(num){
         return function(){
           return num;
         };
       }(i);
    }
    return result;
}
  • 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-27T04:38:42+00:00Added an answer on May 27, 2026 at 4:38 am

    This is short hand for calling the function and passing it the parameter i. It’s like doing this:

    function createFunctions(){
        var result = new Array();
        for (var i=0; i < 10; i++){
            result[i] = myFunction(i);
        }
        return result;
    }
    
    function myFunction(num){
        return function(){
            return num;
        }
    }
    

    Thinking of myFunction as the anonymous function my help you understand what’s going on, so instead of myFunction(i) you have function(num){…}(i);

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

Sidebar

Related Questions

I have followed this tutorial http://blogs.wrox.com/article/creating-a-simple-ipad-application-table-view/ (creating a uitableview and populating it). I want
phew! That was a long title. I'm reading WROX' book on Professional JavaScript for
I got the Wrox.Beginning.JavaScript.3rd.Edition and wanted to start learning it from scratch, then my
Having not done ASP.NET since v1.1, and now blitzing through the Wrox Pro ASP.NET
I am new to php and currently I am reading Wrox Professional PHP 5.
I recently went to the WROX forum. I was led there by GOOGLE. On
I'm starting to learn perl, using the Wrox Beginning Perl available on perl.org and
I am trying to set up a package template in SSIS, following the Wrox
Actually I came up with this question, because of an example in one book
I am running through the Navigating with tables section of Wrox' Professional iPhone Programming

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.