GitHub 6219★

Check if an array is not empty

JavaScript version

const isNotEmpty = (arr) => Array.isArray(arr) && Object.keys(arr).length > 0;

TypeScript version

const isNotEmpty = (arr: any): boolean => Array.isArray(arr) && Object.keys(arr).length > 0;

Examples

isNotEmpty([]); // false
isNotEmpty([1, 2, 3]); // true
Follow me on and to get more useful contents.