Check if element is present in Array. - Node.js Array

Node.js examples for Array:Search

Description

Check if element is present in Array.

Demo Code


Array.prototype.contains = function ( needle ) {
    for (var i in this) {
        if (this[i] === needle) return true;
    }//from  w  w w .  ja  v a 2 s .  co m
    return false;
};

Related Tutorials