Object.prototype.clone

Peter Michaux petermichaux at gmail.com
Mon Oct 22 13:41:43 PDT 2007


On 10/21/07, Kris Zyp <kriszyp at xucia.com> wrote:
> >> http://javascript.crockford.com/prototypal.html
> It is the act of creating a object that inherits from/delegates to the
> provided object. Peter is suggesting sugar for one of the important
> mechanisms in a prototypal language. I believe the "copy" semantic is used
> in Self. "clone" is bit misleading (well, I think "copy" is too). With
> classes, we call it "subclassing". We could call it "subobject" :). Douglas
> calls it "begetObjet" (nice),

"liveClone" appeals to me.


> I personally think it is very valuable
> construct and I like what it encourages,

This is one of the thing's I'm trying to determine. Does it encourage
something really new or is it just some sugar or does it really create
a different mindset in the programmer and hence functionally different
code. Every example I've looked at so far is just as easily coded in
the standard JavaScript way with a constructor, its prototype property
and the "new" keyword.


> but on the otherhand it is so
> easy/compact to create (about 4 lines of code), and it doesn't seem to be
> the direction ES4 is headed, so it's omission seems reasonable.

It seems ES4's big features are to appease the complaints about
JavaScript and make it easier for programmers coming from Java. These
are both worthy goals. However there can still be goodies for the
enlightened ;-)

Peter



More information about the Es4-discuss mailing list