JavaScript — object properties and prototype chain

As we saw in a previous article properties can be created in two different ways. This is by using a literal object notation or by using a function constructor.

Checking object property existence

Using dictionary notation

Using for..in loop

If you are using prototypes in order to avoid displaying the properties higher on the prototype chain you can filter those properties by using

object.hasOwnProperty(property_name) 

Note that if you declare anonymous functions as variables you will have to filter those too with (typeof(person[key]) != “function”). Definition would look like var myFn = function(){…};