News for hackers. Stuff that matters.
Re:JavaScript Tips by giu on Thursday May 06, 2010 @05:45AM (#1324009)
I stumbled upon a few of the mentioned tricks in the article lately, while working on JavaScript projects in my spare time.

Another little trick that I personally like because of its simplicity is the following:

  Array.prototype.clear = function(){this.length=0;}
Clears an Array the easy way.
Re:JavaScript Tips by lhorie on Thursday May 06, 2010 @11:20AM (#1324594)
You just need to be aware that this might cause unexpected behavior when using for ... in

  Array.prototype.clear = function() {this.length = 0};
  var a = [1,2,3];
  var s = "";
  for(var i in a) s += i +",";
  alert(s);//1,2,3,clear
(not that many people use it this way, but since we're on the topic of little known tricks about js, I think it's worth mentioning)