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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:49:54+00:00 2026-05-24T18:49:54+00:00

var myVar = $( [] ); What does this jQuery do? Does it initialize

  • 0
var myVar = $( [] );

What does this jQuery do?

Does it initialize the variable to an empty jQuery set? I have searched the jQuery docs but haven’t found an explaination for this syntax.

Excerpt from the jQuery docs http://api.jquery.com/jQuery/

Returning an Empty Set –

As of jQuery 1.4, calling the jQuery() method with no arguments returns an empty jQuery set (with a length property of 0). In previous versions of jQuery, this would return a set containing the document node.

So could $( [] ) be a legacy method for returning an empty jQuery set or does it do something entirely different?

  • 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-24T18:49:55+00:00Added an answer on May 24, 2026 at 6:49 pm

    While there are different ways to interpret “legacy” (as in pst’s comment), the expression is precisely documented. We know that the $ function is the same as jQuery so looking up jQuery we see it can accept arguments in several different forms:

    • jQuery( selector, [context] )
    • jQuery( element )
    • jQuery( elementArray )
    • jQuery( jQueryObject )
    • jQuery()

    The one accepting an element array is documented like so:

    • elementArray: An array containing a set of DOM elements to wrap in a jQuery object.

    This answers your question “So could $( [] ) be a legacy method for returning an empty jQuery set or does it do something entirely different?” in the sense that no, it does not do anything different. You get a jQuery object with all the elements in your empty array. All zero of them.

    And as you mentioned in your question, as of 1.4, plain ol’ $() gives you the empty set and so I take it that it may be the preferred way to do things now. That said, $([]) is nice and explicit, and still supported.

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

Sidebar

Related Questions

I'm having trouble understanding jQuery variable scope. var myVar; function getMyVar() { myVar =
I've got a variable in Emacs called my-var that I'd like to set whenever
I have a file called 34.php?session=2534464a39a2c97cb7113689726a4e52 in my /var/www/html folder but I can't view
Classic javascript: var myvar = document.getElementById(abc); abc.value += test; abc.value += another test; Jquery:
Aptana is showing error at this line: var myVar = myVar1 = myVar2; although
Why would you use this syntax? var myVar = myArray.length && myArray || myObject;
I have seen in some nodejs scripts variables/objects being used like this: var myvar1
it appears if you have something like var my_var = {foo : bar}; in
Why does the following work from the prompt but fail when stuck inside a
I'm trying to create a dynamically named object. something like private var myVar:String =

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.