mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Don't return the last falsy value when forEach'ing over an array.
This commit is contained in:
parent
7e6f1ab01d
commit
bce8314e0b
@ -28,15 +28,15 @@ module ts {
|
||||
export interface StringSet extends Map<any> { }
|
||||
|
||||
export function forEach<T, U>(array: T[], callback: (element: T) => U): U {
|
||||
var result: U;
|
||||
if (array) {
|
||||
for (var i = 0, len = array.length; i < len; i++) {
|
||||
if (result = callback(array[i])) {
|
||||
break;
|
||||
var result = callback(array[i]);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function contains<T>(array: T[], value: T): boolean {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user