Bug Tracker

Opened 14 years ago

Closed 14 years ago

#3520 closed bug (duplicate)

.eq(n) acts funny

Reported by: sorpigal Owned by:
Priority: minor Milestone: 1.3
Component: core Version: 1.2.6
Keywords: Cc: sorpigal, flesler
Blocked by: Blocking:


When passing .eq() a variable containing an integer parsed out of a string the results are strange. In my case I was passing 0, 1 or 2 based on the values found in a string. When passing 0 and 2 I got expected results, when passing 1 I found that .eq(n).length == 2, which is very wrong.

I do not have a simple test case for this, but the fix is:

eq: function( i ) {

return this.slice( +i, +i + 1 );


The unary + forces i to be a number. I think there is no possible harm to this and it will save many people frustration. Technically, of course, it is user error.

Change History (4)

comment:1 Changed 14 years ago by flesler

Cc: sorpigal flesler added

This should be fixed in trunk.

Can you try with this file ? http://code.jquery.com/jquery-nightly.js

Do post back even if it works so that I can close this.

comment:2 Changed 14 years ago by flesler

If you're interested: #3102

comment:3 Changed 14 years ago by sorpigal

Confirmed, works as expected with nightly.

Sorry, if I had known about that I would have tested before filing.

comment:4 Changed 14 years ago by flesler

Resolution: duplicate
Status: newclosed

No problem.

Note: See TracTickets for help on using tickets.