Haha, no worries Mike. I didn't actually test out the solution till later, and it wasn't until later still that the fact other Objects would have to filter it occurred to me. S'what I get for doing lunch break snippets. :P
Anyway, I have updated the function to no longer use the Object.prototype method, but to add it as a jQuery utility. $.extend({ keys: function(obj){ var a = []; $.each(obj, function(k){ a.push(k) }); return a; } }) // Useage: var obj = {a: 1, b: 2, c: 3, d: 4, kitty: 'cat'} alert($.keys(obj)); // a,b,c,d,kitty On Thu, Dec 11, 2008 at 8:27 PM, Michael Geary <m...@mg.to> wrote: > p.s. Don't get me wrong, Eric, I'm not criticizing you for offering that > possible solution! It's great that you were willing to take the time to give > it a shot. > > I just wish that there were a clean way to add Object methods without > breaking existing code. Ah well, we must play the hand we're dealt... :-) > > -Mike > > ------------------------------ > *From:* Michael Geary > > That code breaks $.each in exactly the same way as Bill's original code. > Note that you had to add an explicit test for the getKeys method name to get > it to work... > > -- Eric Garside Front End Developer LabPrints