JavaScript — object properties and prototype chain

Gerard Sans
Sons of JavaScript
Published in
1 min readDec 13, 2014

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(){…};

--

--

Gerard Sans
Sons of JavaScript

Helping Devs to succeed #AI #web3 / ex @AWSCloud / Just be AWSome / MC Speaker Trainer Community Leader @web3_london / @ReactEurope @ReactiveConf @ngcruise