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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:01:45+00:00 2026-06-10T03:01:45+00:00

EDIT Here is an attempt to make my question simpler. return this.someFunc(); == return

  • 0

EDIT
Here is an attempt to make my question simpler.

return this.someFunc(); == return { XXX:this.someFunc() };

What do I have to put in for XXX to make this statement true?


I’m trying to create a function that can be chained. Let me write some hypothetical code. (Any syntax errors just ignore, I’m typing this fast and this is just concept code.) Assume that all functions are either defined locally or globally. 🙂

test = function(){
  this.someFunc = function(){
    this.retest = function(){
      //...code
    }
    //...code
  }
  this.someFunc2 = function(){
    //...code
  }
  return this.someFunc();
}

This function allows me to chain: test().retest();
But what I want to do is return more than one item.

test = function(){
  this.someFunc = function(){
    this.retest = function(){
      //...code
    }
    //...code
  }
  this.someFunc2 = function(){
    //...code
  }
  return { XXX:this.someFunc(), //What do I put for XXX
           next:this };
}

I want to do this to access another function that test() offers: test().next.someFunc2();

So my problem is this:
I still want to be able to chain like this: test().retest();

But I have to do it like this: test().XXX.retest();

In my code, what is the name that I can put instead of XXX to accomplish this? And is this even possible? I have tried 0 and default already. Thanks for the help.

  • 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-10T03:01:47+00:00Added an answer on June 10, 2026 at 3:01 am

    You can make a chainable functions like this:

    var test = function(){
    
        var self = {};
        console.log('test called')
    
        function someFunc() {
            console.log('someFunc')
            return self;
        }
    
        function someOtherFunc() {
            console.log('someOtherFunc')
            return self;
        }   
    
        self.someFunc = someFunc;
        self.someOtherFunc = someOtherFunc;
        return self;
    
    }
    
    test().someFunc().someOtherFunc();
    

    Hope this helps

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

Sidebar

Related Questions

EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
edit: Ok, to put this in a question, I'm asking for possible ways I
EDIT: Here is the edited control file (control.ascx): <%@ Control Language=C# AutoEventWireup=true CodeFile=Sale.ascx.cs Inherits=Enmasse.Modules.Demo_Enmasse.Sale
Edit: OK I asked the wrong question here. I'm going to be coding a
EDIT Sorry I forgot the most important part here. Each key can have more
* edit have fixed this code - see inline comments marked EDIT * I'm
EDIT: Here's a create script for the table minus the constraints on the keys
When inserting values into my table what do I edit here? Do I delete
When a user links to link it redirects to edit.php - here's an example:
I'm looking to analyze and compare the following `signals': (Edit: better renderings here: oscillations

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.