Bug Tracker

Modify

Ticket #4188 (closed enhancement: fixed)

Opened 5 years ago

Last modified 4 years ago

.get(-n)

Reported by: rkatic Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:

Description

Enable use of negative numbers as argument.

get: function( num ) {
    ...
    return this[ num < 0 ? this.length + num : num ];
}

Change History

comment:1 in reply to: ↑ description ; follow-up: ↓ 2 Changed 5 years ago by rkatic

eq: function( i ) {
	return i == -1 ? this.slice( i ) : this.slice( i, +i + 1 );
},

comment:2 in reply to: ↑ 1 ; follow-up: ↓ 3 Changed 5 years ago by rkatic

An alternative and more optimized solution of eq(n) would be:

eq: function( i ) {
    return this.pushStack( this.get(i), 'eq', i )
}

comment:3 in reply to: ↑ 2 Changed 5 years ago by rkatic

This last solution is not enough to handle the "out of range" case and when value is not true. So forget it.

comment:4 Changed 5 years ago by yehuda

  • Milestone changed from 1.3.2 to 1.3.3

comment:5 Changed 5 years ago by yehuda

  • Status changed from new to closed
  • Resolution set to fixed

Resolved by #6439

comment:6 Changed 5 years ago by john

  • Version changed from 1.3.1 to 1.3.2

Landed .eq(-N) support in SVN rev [6541].

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.