On Fri, Mar 16, 2012 at 4:23 PM, Domenic Denicola <[email protected]> wrote: > In theory I see them as complementary, but in practice I have never been > able to integrate prototypes. Consider: a method can only be attached to a > prototype if it needs access to an instance’s public state only, and not to > its private state. These cases are extremely rare. And when they do occur, I > usually ask myself—is this really an instance-level method? Why not make it > a module-level method that operates on instances of my class?
Note that private Names let you finally get a prototypal method that accesses instance-private data; you create the private Name inside an IIFE along with the constructor and the prototype methods, and use it to access data. Outside the IIFE no one can get to it. (WeakMaps provide the same ability through slightly different functionality, as Rick points out.) ~TJ _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

