I was playing a bit with javascript and found out (at least for me) strange behaviour when dealing with multi-dimensional arrays via a foreach loop. So I have this piece of code
I use this dump() function all the time to debug my multi-dimensional arrays.
http://binnyva.blogspot.com/2005/10/dump-function-javascript-equivalent-of.html
If you have questions about implementing it, let me know.