mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 03:47:50 +00:00
Cleanup _.compact optimization.
This commit is contained in:
10
lodash.js
10
lodash.js
@@ -4501,13 +4501,13 @@
|
|||||||
function compact(array) {
|
function compact(array) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = array ? array.length : 0,
|
length = array ? array.length : 0,
|
||||||
result = [],
|
resIndex = 0,
|
||||||
cur = 0,
|
result = [];
|
||||||
value;
|
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
if (value = array[index]) {
|
var value = array[index];
|
||||||
result[cur++] = value;
|
if (value) {
|
||||||
|
result[resIndex++] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user