Code coverage report for array/indexOf.js

Statements: 100% (11 / 11)      Branches: 100% (6 / 6)      Functions: 100% (3 / 3)      Lines: 100% (10 / 10)     

All files » array/ » indexOf.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 231         1 174 174   174     398 66   332   108     1    
define(function () {
 
    /**
     * Array.indexOf
     */
    function indexOf(arr, item, fromIndex) {
        fromIndex = fromIndex || 0;
        var n = arr.length,
            i = fromIndex < 0? n + fromIndex : fromIndex;
        while (i < n) {
            // we iterate over sparse items since there is no way to make it
            // work properly on IE 7-8. see #64
            if (arr[i] === item) {
                return i;
            }
            i += 1;
        }
        return -1;
    }
 
    return indexOf;
});