Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check empty object javascript

const obj = {};
const obj2 = { n: 1 };

function isObjectEmpty(object) {
  for (const key in object) {
    return !object.hasOwnProperty(key);
  }
  return true;
}

console.log("1", isObjectEmpty(obj));
console.log("2", isObjectEmpty(obj2));
Source by www.samanthaming.com #
 
PREVIOUS NEXT
Tagged: #check #empty #object #javascript
ADD COMMENT
Topic
Name
5+3 =