Console.log weirdness
Wednesday, Sep 14, 2011
I generally use the latest version of Safari or Webkit for my debugging, falling back to Firefox/Firebug for certain tasks that Safari doesn’t handle well. I was working on doing a custom sort function for some javascript objects that I’ll be creating in a project that I’m working on and I couldn’t figure out why it wasn’t working the way I expected. I created a test page so that I could see exactly what was going on.
As you can see, I have the three sorting functions there. Then an array literal that contains a few object literals with some common keys that I’ll be sorting by. The output to the console is where the action is though. When I was looking it in Safari, the output was exactly the same in for all of the console.log statements. No matter what the sort function, the array of objects was always output in the same order. But when I looked at it in Firebug, the sorting functions were doing exactly as expected. Has anyone ever come across this behavior before? Is there something I’m missing? Let me know on twitter
Update: It looks like I'm definitely not the first one to notice this. Guess I should look for the bug someone may have filed about this issue.