Skip to content

Commit c808007

Browse files
committed
Avoid using this if possible in array_count_values
1 parent c067f26 commit c808007

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

functions/array/array_count_values.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ function array_count_values(array) {
2727
return t;
2828
};
2929

30-
var __countValue = function (value) {
30+
var __countValue = function (tmp_arr, value) {
3131
switch (typeof value) {
3232
case 'number':
3333
if (Math.floor(value) !== value) {
3434
return;
3535
}
3636
// Fall-through
3737
case 'string':
38-
if (value in this && this.hasOwnProperty(value)) {
39-
++this[value];
38+
if (value in tmp_arr && tmp_arr.hasOwnProperty(value)) {
39+
++tmp_arr[value];
4040
} else {
41-
this[value] = 1;
41+
tmp_arr[value] = 1;
4242
}
4343
}
4444
};
@@ -47,7 +47,7 @@ function array_count_values(array) {
4747
if (t === 'array') {
4848
for (key in array) {
4949
if (array.hasOwnProperty(key)) {
50-
__countValue.call(tmp_arr, array[key]);
50+
__countValue.call(this, tmp_arr, array[key]);
5151
}
5252
}
5353
}

known_failures.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
array_change_key_case#7
2-
array_count_values#1
3-
array_count_values#2
42
array_diff_uassoc#1
53
array_merge_recursive#1
64
array_splice#1

0 commit comments

Comments
 (0)