I read the article below suggesting to use the built-in array functions in JavaScript. I’ve always heard that those methods are significantly slower than the built-in for
loop, but I never actually measured it myself.
So, I figured now is as good of a time as any. So, let’s go run some tests!
The machine I’m running the code is a MacBook Pro with a 2.5GHz Quad-Core Intel Core i7 processor, and 16GB 1600 MHz DDR3 memory. My node version is 12.14.0.
While the max array length is ²³², my computer actually cannot create an array with that length without a JavaScript heap out of memory
error. Based on local testing, 50 million length array is as high as I am able to go.
These functions will be judged in two ways:
process.memoryUsage().heapUsed
Date
object and first-grade math#javascript #javascript-tips #functional-programming #javascript-development #arrays