Fix index generation for javascript array