2 ms·
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,
by lhorie 17y ago
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)