Javascript Array includes(item)

Description

Javascript Array includes(item)


//modifying the Array class to reuse common methods

Array.prototype.includes = function(item) {
    return this.indexOf(item) > -1;
}

function makeUnique(array) {
    return array.filter(function(element, index) {
        return array.indexOf(element) === index;
    });//from  w  ww .j  a v  a  2s. c o m
}



PreviousNext

Related