Bug Tracker

Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#4188 closed enhancement (fixed)

.get(-n)

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

Description

Enable use of negative numbers as argument.

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

Change History (6)

comment:1 in reply to: ↑ description ; follow-up: Changed 8 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: Changed 7 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 7 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 7 years ago by yehuda

  • Milestone changed from 1.3.2 to 1.3.3

comment:5 Changed 7 years ago by yehuda

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

Resolved by #6439

comment:6 Changed 7 years ago by john

  • Version changed from 1.3.1 to 1.3.2

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

Note: See TracTickets for help on using tickets.