Javascript Array indexOf(d, e)

Description

Javascript Array indexOf(d, e)


Array.prototype.indexOf || (Array.prototype.indexOf = function(d, e) {
    var a;/* w ww.ja  v  a2s . c  om*/
    if (null == this) throw new TypeError('"this" is null or not defined');
    var c = Object(this),
        b = c.length >>> 0;
    if (0 === b) return -1;
    a = +e || 0;
    Infinity === Math.abs(a) && (a = 0);
    if (a >= b) return -1;
    for (a = Math.max(0 <= a ? a : b - Math.abs(a), 0); a < b;) {
        if (a in c && c[a] === d) return a;
        a++
    }
    return -1
});



PreviousNext

Related