Posted by & filed under javascript.

When I’m working with an object and I need to check a property, I cannot go straight up I always first check if this one exists, but we have different ways to check them, before I used to do this.

It works when the property is undefined, but if the property has false ,zero(0), or empty string (“”) it wont work as we wanted.

Other way is checking if it has its own property by using

But here you are just checking the properties that come with the object, not the ones that are inherited by the prototype chain. So in case you want to check all the properties use this code.

It’s really annoying checking long objects structures

Try this snippet:

One Response to “Checking object properties”


  1.  Alexander1
  2.  Alexander7