Code:
var animals = { \"elephant\": { \"name\" : \"Bingo\", \"age\" :
If you want something cross browser, that is also working on IE8, you can't do it in a really clean way (see compatibility of the keys property).
I suggest this :
var n = 0; for (var _ in animals) n++;
(as it is an object literal, no need for hasOwnProperty)