Wednesday, January 16, 2013

Getting properties and functions of JavaScript objects

I was looking for a way to get all the properties and functions for a particular JavaScript object. Looking around the web I found this discussion of StackOverflow which gave me my answer. I created a small helper function to which you pass your object and it spit out all its properties and function in the console. This is how it looks like:

You may argue that content assist in IDEs already give you this information. But there are slight differences in implementation of JavaScript of each browser. Looking into the document object on Chrome I found a property webkitIsFullScreen, but on Firefox there is not corresponding property with name mozIsFullScreen (I am looking at Firefox 16).