time to trim mustache
Tab Atkins Jr.
jackalmage at gmail.com
Fri Jun 1 10:32:49 PDT 2012
On Fri, Jun 1, 2012 at 10:16 AM, David Herman <dherman at mozilla.com> wrote:
> 1. Paving cowpaths: Crockford's closures-for-private-properties pattern but without the per-instance costs:
>
> function CrockClass() {
> var myPrivateData = ...;
> // one copy per instance
> this.myMethod = function(...) {
> ... myPrivatedata ...
> }
> }
>
> // versus:
>
> var myPrivateName = new Name();
> function ES6Class() {
> this[myPrivateName] = ...;
> }
> ES6Class.prototype.myMethod = function(...) {
> ... this[myPrivateName] ...
> }
By the way, I just wrote a more-or-less real-life example for this
yesterday, to help Hixie with speccing something in HTML:
http://www.xanthir.com/blog/b4JB0
~TJ
More information about the es-discuss
mailing list