How to check if the Object is empty?

prasanna kumar
1 min readJul 26, 2020

--

Although there are multiple ways of checking an object is null, here are the different ways of how we can check if an object is Empty.

How to check if an object is empty or not

first, let us create an object.

const empty = { }

1) The first way and older technique

using loadash : )

_.isEmpty(empty); // true

2) The second way and the Newer technique

Using the default Object properties:

Object.keys(empty).length === 0 && empty.constructor === Object //true

Do you have any other ways of checking? let me know in the comments:)

#EnjoyProgramming

--

--

prasanna kumar
prasanna kumar

Written by prasanna kumar

An obvious south Indian engineer

No responses yet