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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:48:59+00:00 2026-06-10T16:48:59+00:00

This is a difficult one to explain, so I welcome comments querying the details.

  • 0

This is a difficult one to explain, so I welcome comments querying the details. Basically with jQuery you can do the following things:

.

What I want

$.ajax().etc()
$("selector").doStuff().etc()

Which means that $ is acting as a function (that is then chainable) as well as an object (also chainable).

.

What I’ve got

I am writing some javascript myself and have successfully made a chainable set of functions like so:

myF.func1().func2()
myF('text') //Cannot get this working!

.

I’m using window.myF=(new myFuncs()) to get the first line working, but I can’t then use myF as a function. I’ve also made it so that myF can be used as a function, but then I can’t chain the other functions.

I’m extremely confused and as much as I’ve tried searching this site and Google, I must be searching the wrong thing as I have no idea where to go from here!

Questions in the comments are welcomed and expected!

.

My Setup (simplified)

(function(){
    var myFuncs=function(){

    };

    myFuncs.prototype = {
          foo: function() {
          }
          ,bar: function() {
          }
    }

    window.myF = (new myFuncs());
})();
  • 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-10T16:49:00+00:00Added an answer on June 10, 2026 at 4:49 pm

    I had a quick look at the jQuery source code and it looks like it doesn’t use prototypes for the jQuery object – the window.$.

    Instead it uses $.extend:

    var myF = function(){};
    $.extend(myF, {
       actAsAnObject: function(){}
    });
    

    However, for what I’ll call the jQuery response object it does use prototypes. So if you call myF() this code gets run:

    var myF = function(){
        return new myF.prototype.init(arguments); // based on the jQuery code
    };
    

    $.post is an object property, you can’t get it if you call the function itself. $().html is a jQuery response object function, it is not a member of the window.$object.


    Answer to your update: http://jsfiddle.net/rmpW8/

    (function(){
        var myFuncExternal = function(num){
            return new myFunc(num);           
        };
        var myFunc = function(num){
            this.num = num;
        };
    
        $.extend(myFuncExternal, {
            foo: function(num){
                console.log("In foo with: " + num);
            }
        })
    
        myFunc.prototype = {
              foo: function() {
                  myFuncExternal.foo(this.num);
              },
              bar: function() {
                  console.log("In bar with: " + this.num)
              }
        }
    
        window.myF = myFuncExternal;
    })();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a kind of difficult one to explain but basically I have a
First things first, i find this one a little difficult to explain, as english
This one is a little difficult to explain so I'll show code first.. Note:
Okay, so this one may be difficult but I will do my best to
This is going to be a bit difficult to explain. I'm usually fine with
This will be a bit difficult to explain but I will try my best.
I'm sure someone can explain this. we have an application that has been in
This is a difficult situation to explain, so bear with me. I have a
Difficult to explain this question. I am attempting to create a set of UIButtons
This is very specific, and a bit difficult to explain, and quite likely impossible,

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.