An example of what I'm talking about.
This implementation, is much faster..
var data = [1, 2, 3, 4];
var currIndex = 0;
var copied = [];
for (var i = 0; i < data.length; i++) {
copied[currIndex] = data[i];
currIndex++;
}
Than this:
var data = [1, 2, 3, 4];
var copied = [];
for (var i = 0; i < data.length; i++) {
copied.push(data[i]);
}
It's obvious that when writing JS, most people would write the second implementation as it's clearer what they're doing. Plus, with the first one, you are re-inventing the wheel.
Not sure why JS functions are so expensive.