Как то так?Javascript имеет отличные возможности для массивов и наборов ключей, а также их комбинаций.
function LAM() {
this.ids = {}
this.indexes = []
}
LAM.prototype.put = function(myObj, id, ix) {
this.ids[id] = myObj
this.indexes[ix] = id
}
LAM.prototype.getByIndex = function(ix) {
return this.ids[this.indexes[ix]]
}
На практике:
? a = new LAM
? a.put("jhgf", "WE", 3)
? a.ids.WE
jhgf
? a.getByIndex(3)
jhgf