Use plain for loop instead of for-in loop to iterate the Array elements to avoid js errors if someone had attached extra methods to the Array.prototype.