Skip to content

Commit 73591a6

Browse files
committed
double check clarification
1 parent 5535103 commit 73591a6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

functions/array/in_array.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ function in_array(needle, haystack, argStrict) {
1818

1919
var key = '',
2020
strict = !! argStrict;
21-
21+
22+
//we prevent the double check (strict && arr[key] === ndl) || (!strict && arr[key] == ndl)
23+
//in just one for, in order to improve the performance
24+
//deciding wich type of comparation will do before walk array
2225
if (strict) {
2326
for (key in haystack) {
2427
if (haystack[key] === needle) {

0 commit comments

Comments
 (0)