Javascript Array findIdx(fn)

Description

Javascript Array findIdx(fn)


/**//  w  ww.java2  s .  c  om
 * Function finds index value for array condition.
 */
Array.prototype.findIdx = function(fn) {
    return this.indexOf(this.filter(val => fn(val))[0]);
};



PreviousNext

Related