Contains in Array - Node.js Array

Node.js examples for Array:Array Operation

Description

Contains in Array

Demo Code


Array.prototype.contains = function(needle) {
    if (Array.prototype.indexOf)
        return this.indexOf(needle) != -1;
    for (var i in this)
        if (this[i] == needle)
            return true;
    return false;
}

Related Tutorials