Two-dimensional array class in JS