“Friend Classes” in javascript
问题 I have a Factory class that creates a Widget object. The Factory object needs to callback a "private method" of the Widget object at a later time to pass it some ajax info. So far, the only implementation I've come up with is to create a public method in the Widget that returns the private method to the factory, and then deletes itself, the Factory then returns the new Widget while retaining a pointer to the private method. Here is a simplified example: function Factory() { var widgetCallback