I want to define some class or object where I can do
Foo['bar']
This get item call should call a function so that I can provide a default or some other logic based on the key. Similar to python's __getitem__
const Foo = {
__getitem__: key => {
if (key in Foo.values) return Foo.values[key]
// other logic
return key
}
}