Ah, you're right about that! I'll fix it when I have a chance, though it wont affect the performance.
You're welcome to clone the repo, make changes, and run the tests yourself (just open index.html in a browser).
I was surprised too, but my rationalization is that the engine has been very optimized towards DOM-like operations for the past decade that doing math is comparatively slower. And another thing could be is that the 2d array could be effectively partitioning the space that the engine has to search in case it's doing something stupid underneath.
One day when I'm brave enough I'll look into the V8 code for arrays and objects.
You're welcome to clone the repo, make changes, and run the tests yourself (just open index.html in a browser).
I was surprised too, but my rationalization is that the engine has been very optimized towards DOM-like operations for the past decade that doing math is comparatively slower. And another thing could be is that the 2d array could be effectively partitioning the space that the engine has to search in case it's doing something stupid underneath.
One day when I'm brave enough I'll look into the V8 code for arrays and objects.