I want to create a datatype or object in javascript that I can access by both index and key, and also I want a length property that shows how many items are in datatype.
Kinda like..
MyDataType[0].name="John"
MyDataType[0].salary="over 1k"
So if I wrote:
MyDataType['John'].salary //I should get "over 1k"
And if I wrote:
MyDataType[0].salary //I should get also "over 1k"
And I would like to have:
MyDataType.length //should return 1
Is this possible? I tried with Proxy and it worked perfect for the index/key part but it didnt have a length property. I tried with array and it had index and length but no access with key
Thanks guys and please help me