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

  • Home
  • SEARCH
  • 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 8097687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:50:19+00:00 2026-06-05T21:50:19+00:00

First, I was calling my functions like this: var a=1; a=foo(a,2); Then I discovered

  • 0

First, I was calling my functions like this:

var a=1;
a=foo(a,2);

Then I discovered prototype and called my functions like this:

var a=1;
a=a.foo(2);

And smaller if it’s for arrays or objects:

var a=[1,2,3];
a.foo(2);

Is there a way to call functions like this: a(2) or a[2] with a hack or something?

  • 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-05T21:50:21+00:00Added an answer on June 5, 2026 at 9:50 pm

    You could do this;

    var a=[1,2,3];
    var m = "reallyLongMethodName";
    a[m](2);
    

    Which would call a.reallyLongMethodName(2) using square bracket notation.

    Things like this is possible in JavaScript:

    var a=[1,2,3];
    var c = a.foo;
    c(2);
    

    But, this won’t work in your case as the this reference inside c would no longer be the array.

    You could fix this using call() or apply();

    c.call(a, 2);
    

    But that’s probably too long for your liking.

    You could also create a wrapper function;

    function c(ar, val) {
        ar.foo(val);
    }
    
    c(a, 2);
    

    … but again, that’s probably too long for your liking ;).

    So all in all, what you’ve got is as short as it’ll be… Congratulations. You’ve made your code as unreadable as possible.

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

Sidebar

Related Questions

I currently use this style to create a js class like structure: var JSClass
I have a code like this function SocialMiner() { var verbose=true; var profileArray=new Array();
When calling a Javascript function, it seems like JS gives priority to functions without
I think I'm missing some key concept regarding objects and prototype functions in JavaScript.
When calling loadClass() on a ClassLoader , does the ClassLoader first check if the
I have two nested packages that I am calling via fast_cgi. From the first
I'm using a script which is calling (via sh.run) net use. On the first
First of all, this isn't for a keylogger, it's for an input in a
first take a look on this picture from localScope app : i have 2
First off, I know this is a base JS issue, not jQuery. I am

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.