Your slides variable is not an Array , but a jQuery object.
.eq() returns a jQuery object, ultimately empty if index is outside the bounds and a negative index counted from the end.
.get() returns a DOM element or undefined if index is outside the bounds and a negative index is counted from the end.
[] returns a DOM element or throws an error if index goes out of bounds.
...
In addition, jQuery methods allow you to interact with a set of elements, as it was alone. So if you do this:
slides.css("left", "-100%");
It applies to every matched element contained in a jQuery object. There is no need to sort them out.
...
Also the preferred way to loop over matched elements is each() method:
slides.each(function (i, el) { var $el = $(el); });
...
A standard convention with a jQuery variable prefix with the $ sign is also set; it makes it easy to distinguish DOM elements from jQuery objects. But this is only a matter of taste.
source share