> > From: Erik Beeson
> > The [n] syntax is just a shortcut for 
> > .get(n):http://docs.jquery.com/Core#get.28_num_.29

> From: Gordon
> 
> I would imagine that the [] syntax would be a bit faster than the
> get() syntax, on the grounds that the former is simply 
> addressing an array, whereas the latter is calling a function 
> and getting the returned result.  I'll have to try 
> benchmarking them in a loop when I've got some free time.

[] is definitely faster, as well as being more concise and straightforward.
No need to benchmark unless you want to know just how much faster. There's
really never any reason to use .get(n) instead of [n].

Here's the code for .get():

   get: function( num ) {
      return num == undefined ?
         // Return a 'clean' array
         jQuery.makeArray( this ) :
         // Return just the object
         this[num];
   },

-Mike

Reply via email to