Filtering

eq

Reduce the set of matched elements to the one at the specified index.

jQuery

var element = elements.eq(2);

Vanilla JS

var element = elements[2];

first

Reduce the set of matched elements to the first in the set.

jQuery

var element = elements.first();

Vanilla JS

var element = elements[0];

last

Reduce the set of matched elements to the final one in the set.

jQuery

var element = elements.last();

Vanilla JS

var element = elements.slice(-1);

slice

Reduce the set of matched elements to a subset specified by a range of indices.

jQuery

var subset = elements.slice(1, 3);

Vanilla JS

var subset = elements.slice(1, 3);

is

Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.

Check if single element match

jQuery

var is = element.is('div');

Vanilla JS

var is = element.matches('div');

Check if at least one of elements in the set match

jQuery

var is = elements.is('div');

Vanilla ES6+

var is = elements.some(x => x.matches('div'));

Vanilla ES5

var is = elements.some(function(element) {
    return element.matches('div');
});

has

Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element.

jQuery

var found = elements.has('div');

Vanilla ES6+

var found = elements.filter(x => x.query('div'));

Vanilla ES5

var found = elements.filter(function(element) {
    return element.query('div');
});

not

Remove elements from the set of matched elements.

jQuery

var found = elements.not('div');

Vanilla ES6+

var found = elements.filter(x => !x.matches('div'));

Vanilla ES5

var found = elements.filter(function(element) {
    return !element.matches('div');
});

filter

Reduce the set of matched elements to those that match the selector or pass the function’s test.

jQuery

var found = elements.filter('div');

Vanilla ES6+

var found = elements.filter(x => x.matches('div'));

Vanilla ES5

var found = elements.filter(function(element) {
    return element.matches('div');
});

map

Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.

jQuery

var result = elements.map(function() {
    return this.id;
});

Vanilla ES6+

var result = elements.map(x => x.id);

Vanilla ES5

var result = elements.map(function(element) {
    return element.id;
});
shopify traffic stats