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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:49:44+00:00 2026-06-13T12:49:44+00:00

I realize that one is a prototype can someone tell me the difference between

  • 0

I realize that one is a prototype can someone tell me the difference between these two?

$.addMessage = function () { 

and

$.fn.addMessage = function () {

From what I can see one extends JQuery and the other JQueryStatic in typescript

interface JQuery {
    addMessage();
}

interface JQueryStatic {
  addMessage();
}
  • 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-13T12:49:45+00:00Added an answer on June 13, 2026 at 12:49 pm

    If you add a function as

    $.addMessage = function(){
    

    you can later access the function as

    $.addMessage()
    

    Semantically, the function has no relation to specific jQuery instances, and may be regarded to as an equivalent of a static method (belongs to a class) in Java.


    If you add a function as

    $.fn.addMessage = function(){
    

    Since jQuery defines $.fn as an alias to $.prototype, this is equivalent to

    $.prototype.addMessage = function(){
    

    Javascript automatically assigns Class.prototype as a prototype of the objects created with new Class(). $(...) uses new $(...) internally, meaning it does create new objects with $ as the constructor. This means that $.fn.addMessage can also be accessed as

    $(".messageContainer").addMessage()
    

    Semantically, $.fn.addMessage is related to specific jQuery instances. It means that this inside the addMessage function does not refer to $.fn, but rather to $(...). $.fn may thus be regarded to as an equivalent of an instance method (belongs to an instance) in Java.


    In other words, if you declare your function as

    $.addMessage = function(){ 
    

    , you use it as

    $.addMessage()
    

    If you declare it your function as

    $.fn.addMessage = function(){
    

    , you use it as

    $(".messageContainer").addMessage()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize that it can depend on certain things (and obviously how efficient the
Can you cast an object to one that implements an interface? Right now, I'm
I am writing a module that provides one function and needs an initialization step,
I'm using two jquery plugins. Both extend jquery with a prototype function removeTag .
I'm currently developing a web application that has one feature while allows input from
Is it possible to set time limit for process? I realize that this can
I realize that this question is not unlike asking someone for the name of
I've been researching and analyzing and I realize that the buttons from the UIAlertView
I realize that I can do this in code, but I was curious if
I recently realized that one of my pages does not contain: $(#form1).validate(); call, however

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.