Created
February 10, 2019 21:26
-
-
Save metavoid/c5df6f4a7d18870e317fa758d72dfe13 to your computer and use it in GitHub Desktop.
Check if Object or Array is empty in JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Check if Object or Array is empty | |
| function isEmpty(obj) { | |
| if (Array.isArray(obj) && obj.length > 0) return false; | |
| if (typeof obj === 'object' && Object.keys(obj).length > 0) return false; | |
| return true; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment