Skip to content

Commit e6a3d00

Browse files
committed
Merge pull request locutusjs#149 from BruceLampson/patch-1
Just to be on the safe side :)
2 parents b3817ab + 652f37d commit e6a3d00

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

functions/array/array_search.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,22 @@ function array_search(needle, haystack, argStrict) {
3030
needle = new RegExp(needle.source, flags);
3131
}
3232
for (key in haystack) {
33-
if (needle.test(haystack[key])) {
34-
return key;
33+
if(haystack.hasOwnProperty(key)){
34+
if (needle.test(haystack[key])) {
35+
return key;
36+
}
3537
}
3638
}
3739
return false;
3840
}
3941

4042
for (key in haystack) {
41-
if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
42-
return key;
43+
if(haystack.hasOwnProperty(key)){
44+
if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
45+
return key;
46+
}
4347
}
4448
}
4549

4650
return false;
47-
}
51+
}

0 commit comments

Comments
 (0)