Implementation of data structures in JavaScript