I wonder if it is possible to hack objects’ constructor to make safe() a generic one for all…
Saikat Guha
1

Possible? Yes. You can monkey patch your environment quite easily inn Javascript.

But I wouldn’t do it. That kind of monkey patch could break numerous pieces of code which rely on the native behaviour, not to mention the adverse performance impact.

My take is that if you feel a need for that, it’s a “code smell” which is there to make you take note of the fact that perhaps you’re doing something wrong.
I’d suggest that if you feel such a need, perhaps what you need is better static analysis in your code. You might want to consider adding FlowType into your stack to make sure you’re not trying to access things you shouldn’t.