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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:31:06+00:00 2026-05-11T19:31:06+00:00

Lately, I have been doing this in an effort to speed up performance (and

  • 0

Lately, I have been doing this in an effort to speed up performance (and sometimes it helps with maintainability)

var objectToReference = $('div .complicated #selector ul:last');

So what does objectToReference really hold? Sometimes things have bitten me, so I’ve gone back to using the full selector and it has worked.

So does the variable hold a reference, a pointer, etc (I’m not sure the exact definition of those terms)

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-11T19:31:06+00:00Added an answer on May 11, 2026 at 7:31 pm

    A best practice that many people use when they create a variable like this is to name it starting with $, to indicate that it is a jquery object. So you could name the variable $o, and you can directly call other jQuery chain functions after it, without having to put $() around the variable.

    $o.hide();
    

    It is a good idea to start with the surrounding element for the area you are manipulating, to avoid having to search the entire document. For example, to get all links within a single section of the document (without having to search the whole document):

    var $o = $('#mysection');
    var $links = $('a', $o); // equiv to $o.find('a')
    

    Finally, it never hurts to pass a jQuery object back through jQuery:

    $o === $($o)
    

    This has a nice side effect – you can write a function that accepts any of the following as an argument: a selector, an element, or a jQuery object:

    function myFunc(e) {
        var $e = $(e);
    }
    // All of the following will work:
    myFunc('#mysection');
    myFunc(document.getElementById('mysection'));
    myFunc($('#mysection a'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My background is primarily as a Java Developer, but lately I have been doing
I have been doing some research lately over my work project, i am trying
I have been doing a lot of unit testing lately with mocking. The one
I've been doing some Web-Projects lately that rely on heavy Data-Binding and have been
Lately i have been wondering if there is a performance difference between repeating the
I have been doing some research lately about best approaches to authenticating web services
Lately I have been creating PowerPoint presentations to companies. I have mostly been doing
I have been doing some catching up lately by reading about cloud hosting. For
I have been doing some Windows Assembly Language programming lately and I realized that
Lately I have been doing some numerical method programming in C. For the bug

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.