Brendan Eich wrote:
Again, nothing is new about value object constructors. Most
constructors can be called as functions (not via new) to construct.
Emphasis on "constructors" here. The novelty with value objects is not
in constructors callable without 'new', but in what I went on to write:
Value objects are new under the sun. They are not the same as the
primitive AKA value types built into JS. They are typeof-type "object"
but equal by value not reference (under the hood there's a
pointer-compare fast path, of course). They are frozen so you can't
decorate them with expandos to break this equivalence.
Hope this is clear. To your point, and as Francois posted, teaching
people to leave out 'new' is not going to work in various cases. Better
to teach subsets starting with ES5 strict or smaller, and build up from
there (including XHR at some point). A fair amount (not all) of ES6
should be "more advanced", not "beginner".
In general, trying to teach new stuff that's optional-by-design
(remember, 1JS) as if it were usable exclusive of old stuff looks like a
mistake to me.
If there's a great ES6->ES5 transpiler (traceur is shaping up nicely,
thanks Arv) then perhaps. That is still in the future, in part because
ES6 is not done yet, nor is traceur -- and nor is experience with such a
"JS pedagogy" built on a future-subset-first teaching approach.
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss