js check if object is empty
function isObjectEmpty(obj) {
return Object.keys(obj).length === 0;
}function isEmptyObject(obj) {
return !Object.keys(obj).length;
}> !!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;}// because Object.keys(new Date()).length === 0;
// we have to do some additional check
Object.keys(obj).length === 0 && obj.constructor === Object
Also in JavaScript:
- javascript write to file
- js indexof string
- transition event listener does not work
- object literal javascript
- javascript get timestamp codegrepper
- nativescript vue get native from ref
- regex special characters javascript
- mysql json_extract remove quotes
- How to create a function in javascript
- jimp get image size
- how to remove spaces in javascript
- javascript pluck from array of objects
- default pool size in sequelize
- js email regex
- js class async constructor
- alert jquery
- apollo server build schema passing parameters to classes
- Hide elements until Alpine Js loads
- knex referenced column 'id' in foreign key constraint 'ponto_items_pt_id_foreign' are incompatible.
- js check if variable is string
- onfocus jquery
- javascript style inline react
- Javascript format to currency
- javascript check if undefined or null