« links for 2006-07-02 | Main | links for 2006-07-03 »

A debugging statement

I am writing a shopping cart controller in JavaScript and CSS for the last few days. It's rather complex, and tonight I found I had written this debugging statement:

 alert((function(){var a=""; for(var i in controller){a+=i+" : "+controller[i];return a;}})()); 

which I quickly realized should be amended to

  alert((function(){var a=''; for(var i in controller){a+=i+" : "+controller[i];}return a;})());

which then became

alert((function(){var a=''; for(var i in controller){a+="\n"+i+" : "+controller[i];}return a;})());

and finally in exasperation,

  alert((function(){var a=''; for(var i in controller){a+="\n"+i+" : ";}return a;})());