Optimise array accesses in node.js output