[jQuery] Re: Best way to grab an item from an object?

2008-11-26 Thread Dave Methvin
You'd need to iterate through them, but if you're exclusively using the id to retrieve them you could use this: var TESTS = { "1": { id: 1, name: 'Test 1', }, "2": { id: 2, name: 'Test 2', } }; var

[jQuery] Re: Best way to grab an item from an object?

2008-11-26 Thread ricardobeat
That's an array of objects, and yes, you'll have to iterate through all of them. jQuery can make it a bit easier but it's not actually 'faster'. I think you meant 'shortest' :) var idOne = $.grep(TESTS, function(obj){ return (obj.id == 1); }); - ricardo On Nov 26, 1:38 pm, Shazzaam <[EMAIL P