Javascript Array find(callback, thisArg)

Description

Javascript Array find(callback, thisArg)


Array.prototype.find = function (callback, thisArg) {
    if (typeof thisArg !== 'undefined') {
        // eslint-disable-line gxrules/no-typeof
        callback = callback.bind(thisArg);
    }/*  w ww. j  a  v  a 2 s  .c om*/
    for (var i = 0; i < this.length; i++) {
        if (callback(this[i], i, this)) {
            return this[i];
        }
    }
};



PreviousNext

Related