Hacker News new | ask | show | jobs
by yawaramin 2329 days ago
At compile time? It's very simple–use an interface and provide constructor functions that upcast object instances to the interface. Now, only the interface-defined members i.e. the public members are accessible.

At runtime? You can't, it's JavaScript, everything is public (for now at least).