News for hackers. Stuff that matters.
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)

There are no comments on this comment yet.