Find array by key - Node.js Array

Node.js examples for Array:Search

Description

Find array by key

Demo Code


Array.prototype.findByKey = function( key, value ) {
    for ( var i = 0, n = this.length; i < n; i++ ) {
        if ( this[ i ][ key ] === value ) return this[ i ];
    }/*from w  ww  .j  ava2 s  .  co  m*/
    return false;
};

Related Tutorials