I know it's a matter of taste, but for my taste using for loop each time I want to iterate over array is bad. So I came up with this:
Array.prototype.each = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i]);
}
Now I can do:
[10, 20, 30].each(function(n) { console.log(n/10) })
Later I found some tips on the Internet that suggested this approach, but I still wonder if it's free from side effects. It seems very obvious, and that is what worries me :)
I'm not using any library like jQuery or Prototype. I'm coding for Node.js.