What is the difference between using .first () and .eq (0)?

What is the difference between using these two methods to extract the first item in a collection?

+4
source share
2 answers

Adapted from jQuery 1.7.1 source code :

,first:function(){return this.eq(0)},last:function(){return this.eq(-1)} 

Since you suspected .first() is just a wrapper calling .eq() .

Conclusion: no difference. :)

+10
source

As far as I know, there is no difference.

+1
source

All Articles