1

I am almost new to JQuery. So please forgive if it is trivial.

What does this mean in JQuery: var Utilities = $([]);

Is this like defining an array? Any links to an example?

Some more info: After defining that in the code I see:

Utilities.Message = ' some message';
Utilities.function1 = function(message) { some code };
Utilities.function2 = function() { some code};

calling the method: Utilities.function2();

Thanks, -Sara.

Sara
  • 2,417
  • 7
  • 35
  • 52
  • 1
    That appears that they are just creating a jQuery selector with no elements selected. jQuery selectors are simply an array of DOM elements. – jasonmerino Jan 23 '13 at 23:03

2 Answers2

3

$([]) would use the jQuery( elementArray ) signature to create an empty jQuery collection.

The jQuery() signature, that now does the same, wasn't available until jQuery 1.4, so jQuery([]) could be used before that and can still be used to be compatible with older versions of the library.

Prior to 1.4, jQuery() would do the same as jQuery(document).

Jonathan Lonowski
  • 121,453
  • 34
  • 200
  • 199
1

I don't think that means anything. I don't believe you can ave an array as a selector like that.

Defining an array would be:

var Utilities.Urls = [];

This has some good info: defining array in javascript

Community
  • 1
  • 1
dmgig
  • 4,400
  • 5
  • 36
  • 47
  • Thank you. Actually I am reviewing my a senior person's code. So this should be correct. I will elaborate more on the question. – Sara Jan 23 '13 at 22:51