How to 'pop' or 'shift' from jQuery set

Viewed 37189

In Javascript, arrays should have methods pop and shift.

However, JQuery objects seem to be missing these methods:

$('div').shift(); // Error, shift is undefined
$('div').pop(); // Error, pop is undefined
$('div').splice(); // Splice is OK actually

I wonder why these functions are missing - after all, the jquery object is just an array.

What's the easiest way of performing pop and shift functions on jquery objects?

6 Answers
var $firstDiv = $( $('div').splice(0, 1) );
Related