8000 Simplify `baseUnset`. · lodash/lodash@9a02bd5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a02bd5

Browse files
committed
Simplify baseUnset.
1 parent 89656fd commit 9a02bd5

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lodash.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3881,14 +3881,8 @@
38813881
var previous = index;
38823882
if (isIndex(index)) {
38833883
splice.call(array, index, 1);
3884-
}
3885-
else {
3886-
var path = castPath(index, array),
3887-
object = parent(array, path);
3888-
3889-
if (object != null) {
3890-
delete object[toKey(last(path))];
3891-
}
3884+
} else {
3885+
baseUnset(array, index);
38923886
}
38933887
}
38943888
}
@@ -4352,8 +4346,7 @@
43524346
function baseUnset(object, path) {
43534347
path = castPath(path, object);
43544348
object = parent(object, path);
4355-
var key = toKey(last(path));
4356-
return !(object != null && hasOwnProperty.call(object, key)) || delete object[key];
4349+
return object == null || delete object[toKey(last(path))];
43574350
}
43584351

43594352
/**

0 commit comments

Comments
 (0)
0