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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:01:46+00:00 2026-05-15T13:01:46+00:00

I am having trouble understanding this code: $.functionone = function(){ function setOptions(newOptions){ … }

  • 0

I am having trouble understanding this code:

$.functionone = function(){
  function setOptions(newOptions){
      ...
  }
  this.setOptions = setOptions;
}

what does adding ‘this’ in ‘this.setOptions’ for? I understand that its referencing the function setOptions, but does adding the ‘this’ there make the function get called? I know this refers to the DOM element, but whats the point of having it in this particular scenario. Thanks.

  • 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-15T13:01:46+00:00Added an answer on May 15, 2026 at 1:01 pm

    That will simply expose the function from the scope of functionone, to be a property of the $ object.

    For example:

    $.functionone = function(){
    
      function setOptions(newOptions){
        //...
      }
      this.setOptions = setOptions;
    };
    
    typeof $.setOptions; // "undefined", it doesn't exist
    $.functionone();
    typeof $.setOptions; // "function"
    

    The this value on JavaScript is set implicitly when you make a function call.

    If the function is bound as a property of an object (like $.functionone), the this value will refer to the base object ($ in your example).

    That’s not so useful IMO, it’s equivalent to:

    $.functionone = function(){
      this.setOptions = function (newOptions) {
        //...
      };
    };
    

    Which is at the end, when you invoke functionone, equivalent to:

    $.setOptions = function (newOptions) {
      //..
    };
    

    The difference is that the function is not named, which can be useful for debugging.

    Working with the this value on jQuery plugins is more usual when you extend the jQuery.fn object, in that case the this value refers to the jQuery object that contains the matched elements, and not to the jQuery constructor itself.

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

Sidebar

Ask A Question

Stats

  • Questions 515k
  • Answers 515k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Okay, here we go. I used the x flag to… May 16, 2026 at 6:40 pm
  • Editorial Team
    Editorial Team added an answer A very simple route: filepath.Replace("\", "/").Replace("%", "%25").Replace(" ", "%20").Replace("&", "&") May 16, 2026 at 6:40 pm
  • Editorial Team
    Editorial Team added an answer I think your query is equivalent to this: update a… May 16, 2026 at 6:40 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm having trouble understanding how QGraphicsItemAnimation's setScaleAt function works. Here's the code I'm using:
I'm learning F#, and I am having trouble understanding why this crashes. It's an
I'm new to Ruby, so I'm having some trouble understanding this weird exception problem
I'm having trouble understanding why arrays in C# are covariant and what benefits this
I am modifying some code and came across a declaration that I am having
Can you please explain this code? It seems a little confusing to me Is
So I was looking at this code from a textbook: for (int i=0; i<N;
I'm having some trouble figuring out how to take out what is not necessary
Here is a code form a PHP+MySQL book I am reading and I am
I have just started reading through The C Programming Language and I am having

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.