Performance optimizations taken: prefer array indexing over spreading (~90% faster) [https://jsbench.me/f2l6qlcmfi/1]