how to check if a javascript object is empty
function isObjectEmpty(obj) {
return Object.keys(obj).length === 0;
}function isEmptyObject(obj) {
return !Object.keys(obj).length;
}// because Object.entries(new Date()).length === 0;
// we have to do some additional check
Object.entries(obj).length === 0 && obj.constructor === Objectfunction isEmpty(obj) { return Object.keys(obj).length === 0;}
Also in JavaScript:
- aos library animation angular
- react file input
- age calculator javascript
- javascript ascending and descending
- js split array into smaller arrays
- return value from javascript function
- append to array js
- gatsbyjs image sharp
- js add animation to element
- array sorting javascript insertion sort
- how to change a string to number in javascript
- javascript sum array of objects
- how to use react-fontawesome
- const in javascript
- How to make PWAs installable js
- output event angular
- js percorrer objeto
- react native toggle button with text
- js .length
- react how to export component
- javascript remove first space in string
- set cookie in node
- react native layout animation
- flatten nested array javascript