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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:56:00+00:00 2026-05-28T15:56:00+00:00

Maybe a bad title, but this is my problem: I’m building a framework to

  • 0

Maybe a bad title, but this is my problem:
I’m building a framework to learn more about javascript. And I want to use “”jQuery”” style.

How can I make a function where the () is optional?

$("p").fadeOut(); //() is there
$.each(arr, function(k, v) {...}); //Dropped the (), but HOW?

This is what I have come up with, but it don’t work:

$2DC = function(selector)
{
    return new function() {
        return {
            circle : function()
            {
                //...
            }
        }
    }
}


$2DC("#id1"); //Work
$2DC("#id2").circle(); //Work
$2DC.circle(); //DONT WORK
  • 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-28T15:56:01+00:00Added an answer on May 28, 2026 at 3:56 pm

    $ is really just an alias for the jQuery function. You can call the function with:

    jQuery("p"); or $("p");

    but remember, in JavaScript you can attach “stuff” directly to functions.

    function foo(){
    }
    foo.blah = "hi";
    foo.func = function() { alert("hi"); };
    
    foo.func(); //alerts "hi"
    

    This is how (conceptually) jQuery’s each function is defined.

    jQuery.each = function(someArr, callback) { ...
    

    And so now jQuery.each is a function that can be called like this:

    jQuery.each([1, 2, 3], function(i, val) {
    });
    

    or the more familiar

    $.each([1, 2, 3], function(i, val) {
    });
    

    So for your particular case, to support:

    $2DC.circle(); 
    

    You’d have to add the circle function directly to $2DC:

    $2DC.circle = function(){
       // code
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe I'm just thinking about this too hard, but I'm having a problem figuring
Maybe the need to do this is a 'design smell' but thinking about another
This is maybe a stupid question, but I want to know if my code
Maybe I'm having a bad day, but I can't seem to combine these 2
Maybe I'm having a really bad day, but could someone possibly help me to
Maybe this is a dumb question, but is there any way to convert a
Maybe world peace would be easier, but I have a problem with the widths
Maybe a very basic problem, but i don't get it ... I've written my
Maybe it is a bad habit which I still have since Flash Professional, but
Maybe a bad topic, but given the following code, do i need to free(player->name)

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.