Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to check empty object js

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 medium.com #
 
PREVIOUS NEXT
Tagged: #check #empty #object #js
ADD COMMENT
Topic
Name
7+8 =