Function
isEmpty (obj) Boolean public
Module:
@ember/utils
Defined in packages/@ember/-internals/metal/lib/is_empty.ts:5
import { isEmpty } from '@ember/utils'; |
- obj
- Object
- Value to test
- returns
- Boolean
Verifies that a value is null
or undefined
, an empty string, or an empty
array.
Constrains the rules on isNone
by returning true for empty strings and
empty arrays.
If the value is an object with a size
property of type number, it is used
to check emptiness.
1 2 3 4 5 6 7 8 9 10 11 12 |
isEmpty(null); // true isEmpty(undefined); // true isEmpty(''); // true isEmpty([]); // true isEmpty({ size: 0}); // true isEmpty({}); // false isEmpty('Adam Hawkins'); // false isEmpty([0,1,2]); // false isEmpty('\n\t'); // false isEmpty(' '); // false isEmpty({ size: 1 }) // false isEmpty({ size: () => 0 }) // false |