Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 492b0cd

Browse files
committed
perf(forEach): use native for loop instead of forEach for Arrays
Conflicts: src/Angular.js
1 parent 51863f8 commit 492b0cd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Angular.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,12 @@ function forEach(obj, iterator, context) {
240240
iterator.call(context, obj[key], key);
241241
}
242242
}
243-
} else if (obj.forEach && obj.forEach !== forEach) {
244-
obj.forEach(iterator, context);
245-
} else if (isArrayLike(obj)) {
246-
for (key = 0; key < obj.length; key++)
243+
} else if (isArray(obj) || isArrayLike(obj)) {
244+
for (key = 0; key < obj.length; key++) {
247245
iterator.call(context, obj[key], key);
246+
}
247+
} else if (obj.forEach && obj.forEach !== forEach) {
248+
obj.forEach(iterator, context);
248249
} else {
249250
for (key in obj) {
250251
if (obj.hasOwnProperty(key)) {

0 commit comments

Comments
 (0)