Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1732,11 +1732,13 @@ <h2 id="objects">Object Functions</h2>
</pre>

<p id="isEmpty">
<b class="header">isEmpty</b><code>_.isEmpty(object)</code>
<b class="header">isEmpty</b><code>_.isEmpty(collection)</code>
<br />
Returns <i>true</i> if an enumerable <b>object</b> contains no
values (no enumerable own-properties). For strings and array-like
objects <tt>_.isEmpty</tt> checks if the length property is 0.
Returns <i>true</i> if <b>collection</b> has no elements. For strings
and array-like objects <tt>_.isEmpty</tt> checks if the length property
is 0. For other objects, it returns <i>true</i> if the object has no
enumerable own-properties. Note that primitive numbers, booleans and
symbols are always empty by this definition.
</p>
<pre>
_.isEmpty([1, 2, 3]);
Expand Down
2 changes: 2 additions & 0 deletions modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,8 @@ export function isEqual(a, b) {
// An "empty" object has no enumerable own-properties.
export function isEmpty(obj) {
if (obj == null) return true;
// Skip the more expensive `toString`-based type checks if `obj` has no
// `.length`.
if (isArrayLike(obj) && (isArray(obj) || isString(obj) || isArguments(obj))) return obj.length === 0;
return keys(obj).length === 0;
}
Expand Down
2 changes: 2 additions & 0 deletions underscore.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion underscore.js.map

Large diffs are not rendered by default.