To explain a bit further: when you do `for (key in obj)`, key is bound to each of the object keys, not their values. So, key will be:
'prop01', 'prop02', 'prop03', 'prop04', 'prop05', 'prop06' (but don't count on the order, it's not implementation defined) Then when you do obj_1['prop01'] you get 'PROP-01'. If you use underscore, you can iterate of the keys *and* values with an iterator function, like so: _.each(obj_1, function (key, value) { console.log(key); if (typeof value === 'function') { console.log(value()); } else { console.log(value); } }); It's a bit of extra overhead but I'd argue that it's much cleaner and clearer. Cheers! Nick On 1 December 2011 03:44, Jarek Foksa <ja...@kiwi-themes.com> wrote: > Inside the for loop you should be checking whether : > > typeof obj_1[pro] === 'function' > > not whether: > > typeof pro === 'function' > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/jsmentors@jsmentors.com/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/jsmentors@googlegroups.com/ > > To unsubscribe from this group, send email to > jsmentors+unsubscr...@googlegroups.com > -- Nick Morgan http://skilldrick.co.uk @skilldrick Save our in-boxes! http://emailcharter.org -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com