and then if you are storing nested objects or arrays? good luck with that one
_____ From: Oskar Krawczyk [mailto:[email protected]] Sent: Saturday, 12 June 2010 9:55 PM To: [email protected] Subject: Re: [Moo] Re: fastest way to check if 2 objects are equal I never said it was. Bottom line: iterate through all key-values, and forget about performance issues. O. On 12 Jun 2010, at 12:19, אריה גלזר wrote: wont work. look here: http://jsfiddle.net/AZwgz/6/ since you're not making any distinction between key and value, mixing them will give false positives, and this isn't a long-shot scenario. On Sat, Jun 12, 2010 at 12:19 PM, Oskar Krawczyk <[email protected]> wrote: This is kinda hardcore but still works: http://jsfiddle.net/oskar/AZwgz/2/ O. On 12 Jun 2010, at 09:35, אריה גלזר wrote: yep. but doing something that isn't order specific and infinite depth is extremely expensive - i would need to go key-by-key, check if 2 objects have them, and then check if they are objects and so on. this is a lot of work for the browser for something that can happen quite a lot on my application - to be more specific - HistoryManager <http://mootools.net/forge/p/historymanager> - where creating a noticeable delay is not an option. since he keys are JS generated, i can assume that they are in the same order. On Sat, Jun 12, 2010 at 10:19 AM, amadeus <[email protected]> wrote: Couldn't this cause some problems if the key:val pairs aren't written out in the same order? var obj1 = { cool:'sauce', abc:1 }; var obj2 = { abc:1, cool:'sauce' }; JSON.encode(obj1); // returns "{"cool":"sauce","abc":1}" JSON.encode(obj2); // returns "{"abc":1,"cool":"sauce"}" Even though technically speaking, they both have 'identical data' (whatever that means :) ) -- Arieh Glazer אריה גלזר 052-5348-561 5561 -- Arieh Glazer אריה גלזר 052-5348-561 5561
