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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:32:20+00:00 2026-05-25T19:32:20+00:00

Which is better performance wise. foo(this); function foo(element) { $(element).index(); } Or should I

  • 0

Which is better performance wise.

foo(this);

function foo(element) {

    $(element).index();

}

Or should I do

foo($(this));

function foo($element) {

    $element.index();

}

Obviously taking into account that I will be using the argument a fair few times inside the function.

Thanks!
Connor

  • 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-25T19:32:20+00:00Added an answer on May 25, 2026 at 7:32 pm

    It doesn’t matter where you wrap an object on jQuery if you’re going to wrap it anyway.

    It only matters that you cache the wrapping result and don’t wrap it twice.

    For that matter the following rules apply to many plugins’ code:

    1) jQuery vars are all prefixed with $: var $this = $(this)

    2) never wrap $-prefixed var in $

    3) always cache (save to var) any jQuery-wrapped expression used more than once

    4) if the same wrapped object (like var $items = $('ul li');) occurs more than once in several similar functions, move it to the outer scope and rely on closure.

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

Sidebar

Related Questions

Which one is better when performance is taken into consideration an if else if
In ASP.NET which is better performance wise; Localization using the file based resx /
Which method is better (performance-wise) if I have DataBoundControl such as GridView, Repeater, and/or
Performance wise which one is better: $(.myclass).eq(0) OR $(a.myclass) Note: If there is only
A quick question, which is better performance and memory wise: <t:outputText escape=false value='<tr><td>'/> or
which is better, performance-wise, when you potentially have an empty list? if (_myList !=
Which code snippet will give better performance? The below code segments were written in
Which one is better from performance view user control or custom control? Right now
Which one of the C# <Key, Value> structure implementations has better performance and higher
Between HtmlSelect and DropDownList, which one has a better performance (initialized and rendered faster)?

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.