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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:46:08+00:00 2026-06-06T18:46:08+00:00

Excuse me first. because i don’t know this is question is valid or not.

  • 0

Excuse me first. because i don’t know this is question is valid or not. i if any one clear my doubt then i am happy.

Basically : what is the different between calling a method like:

  1. object.methodname();

  2. $(‘#element’).methodname();

calling both way is working, but what is the different between, in which criteria make first and second type of methods. is it available in the core javascript as well?

In case if i have a function is it possible to make 2 type of method call always?

Can any one give some good reference to understand correctly?

Thanks in advance.

  • 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-06T18:46:09+00:00Added an answer on June 6, 2026 at 6:46 pm

    The first syntax:

    object.methodName();
    

    Says to call a function, methodName(), that is defined as a property of object.

    The second syntax:

    $('#element').methodname();
    

    Says to call a function called $() which (in order for this to work) must return an object and then call methodname() on that returned object.

    You said that “calling both way is working,” – so presumably you’ve got some code something like this:

    var myObject = $('#element');
    myObject.methodname();
    

    This concept of storing the result of the $() function in a variable is commonly called “caching” the jQuery object, and is more efficient if you plan to call a lot of methods on that object because every time you call the jQuery $() function it creates another jQuery object.

    “Is it available in the core javascript as well?” Yes, if you implement functions that return objects. That is, JS supports this (it would have to, since jQuery is just a JS library) but it doesn’t happen automatically, you have to write appropriate function code. For example:

    function getObject() {
       return {
          myMethod1 : function() { alert("myMethod1"); return this; },
          myMethod2 : function() { alert("myMethod2"); return this; }
       };
    }
    
    getObject().myMethod1().myMethod2();
    

    In my opinion explaining this concept in more depth is beyond the scope of a Stack Overflow answer – you need to read some JavaScript tutorials. MDN’s Working With Objects article is a good place to start once you have learned the JS fundamentals (it could be argued that working with objects is a JS fundamental, but obviously I mean even more fundamental stuff than that).

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

Sidebar

Related Questions

First: Excuse me if the question is wrong, I don't really know how to
First, excuse me please, this is not a programming question, but I think it
First of all, I'm new to this so excuse my any simplest question. I'm
this is my first question here, so excuse me if I made any mistakes!
First of all, excuse my ignorance as this issue is not my specialty: I
This is my first post on stackoverflow, so please excuse me if my question
First of all, please excuse any typo, English is not my native language. Here's
First of all, please excuse any typo as English is not my native language.
First of all excuse me for my english. This is my first question here.
First off: I am not an expert, so please excuse any mistakes I make

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.