Implementation of data structures in javascript