diff --git a/collections/object/check-if-an-object-is-empty.md b/collections/object/check-if-an-object-is-empty.md new file mode 100644 index 00000000..76045a9c --- /dev/null +++ b/collections/object/check-if-an-object-is-empty.md @@ -0,0 +1,7 @@ +~~~ javascript +const isEmpty = (obj) => Object.keys(obj).length === 0 && obj.constructor === Object; + +// Examples +isEmpty({}); // true +isEmpty({ name: 'nick' }); // false +~~~ \ No newline at end of file