demo/typescript.js
function forEach(array, callback) {
        if (array) {
            for (var i = 0, len = array.length; i < len; i++) {
                var result = callback(array[i], i);
                if (result) {
                    return result;
                }
            }
        }
        return undefined;
    }
function forEach(array, callback) {
        if (array) {
            for (var i = 0, len = array.length; i < len; i++) {
                var result = callback(array[i], i);
                if (result) {
                    return result;
                }
            }
        }
        return undefined;
    }
function forEach ( array , callback ) { if ( array ) { for ( var i = 0 , len = array . length ; i < len ; i ++ ) { var result = callback ( array [ i ] , i ) ; if ( result ) { return result ; } } } return undefined ; }
Iterates through 'array' by index and performs the callback on each element of array until the callback
returns a truthy value, then returns that value.
If no such value is found, the callback is applied to each element of array and undefined is returned.
Iterates through array by index and performs the callback on each element of array until the callback returns a truthy value then returns that value . If no such value is found the callback is applied to each element of array and undefined is returned .