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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:48:01+00:00 2026-06-07T06:48:01+00:00

I want to define a self executing anonymous function, but have it run several

  • 0

I want to define a self executing anonymous function, but have it run several times with different parameters.

(function(x){ console.log(x*x)})(2)
// output: 4

// I know this syntax is wrong, I am
// demonstrating how I would imagine it being implemented
(function(x){ console.log(x*x)})(2)(5)
// output is error, desired output: 4{Newline}25

Is it possible?


Edit: Based on answer from @Charmander, it seems it is possible
and almost certainly a bad idea, but this works as I would expect…

(function(x){ console.log(x*x); return arguments.callee})(2)(5)
  • 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-07T06:48:03+00:00Added an answer on June 7, 2026 at 6:48 am

    You can either store the anonymous function in a variable.

    var someFunction = function(x){
       console.log(x*x);
    };
    
    someFunction(5);
    someFunction(6);
    

    Or you could have the function return itself if you are really bent on making it an immediately-invoked function expression (iife).

    (function(x){
       console.log(x*x);
       return arguments.callee;
    })(5)(6);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to define different parameter according to different device, but I got a
I have two different classes, and I want to define the addition of them
I want to define a function available_translations which lists the translations I have made
I want to define a generic function for printing contents of std::map like types.
I want to define a following function: if(stmtToFinalize) { NSLog(@Finalizing statement stmtToFinalize); if (sqlite3_finalize(stmtToFinalize)
I want to define operators for a class instance within a class function, like
I want to define several plugins. They all inherit from the superclass Plugin. Each
I have a struct for which i want to define a relative order by
I have a class Parent . I want to define a __new__ for Parent
I want to create a large (~300,000 entries) List of self defined objects of

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.