Check if array has a key - Node.js Array

Node.js examples for Array:Array Operation

Description

Check if array has a key

Demo Code


Array.prototype.hasKey = function(key, label){
    return this.filter(function(e){
        return e[key] === label;
    }).length;/*from   w  ww.j  av  a  2s.  c o  m*/
}

Related Tutorials