On Fri, Jun 1, 2012 at 10:16 AM, David Herman <[email protected]> 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
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to