JSFiddle - React, Tailwind, and code Playground
by Nick Hulea
JavaScript
const isEmpty = (obj) => {
return new Promise(function(resolve, reject) {
if (!obj) reject(new Error(`No Object`))
resolve(Object.entries(obj).length === 0 && obj.constructor === Object)
})
};
let obj = {};
isEmpty(obj)
.then(function(result) {
console.log('is the object empty ' + result)
})
.catch(function(error) {
console.error('error: ' + error)
});