This project is archived and is in readonly mode.

#1067 ✓wontfix
Arieh

Object.create Implementation?

Reported by Arieh | November 4th, 2010 @ 03:27 PM

Is there any plans of implementing Object.create for not ES5 browsers?
It seems like Object.clone is very much the same only it doesn't implement the 2nd argument (a second list of parameters).

I know implementing it as a standalone is quite easy, but it seems like a good addition to "Javascript done right" - it's an inheritance model for objects that don't require a constructor.

Again - I know this can be easily achieved with Moo 1.3 syntax like:

    var a = {a:'a'};
    var b = Object.clone(a);
    Object.extend(b,{b:'b'});

But it's more syntax and less readable. Also, as I understand, Object.create is the way JS is implementing Object.clone.

I suppose somewhere there is a good explanation why once was chosen and not the other, but I couldn't find it.

Comments and changes to this ticket

  • Jan Kassens

    Jan Kassens November 4th, 2010 @ 05:34 PM

    I think we should add Object.create.

  • Arieh

    Arieh November 4th, 2010 @ 05:38 PM

    OK - so after reading the specs a little more I found out that I wasn't quite getting how the Object.create second param works, so now I see that this won't actually be as useful as I thought (I was sure it was possible to pass a normal literal object but it seems you have to use the full defineProperty syntax, which is not at all useful IMO). Also I see why this won't be worth the while creating.
    I guess a clone+extend would still be nice, but not sure if it's actually relevant, since if you're cloning and extending, you're already using all the heavy lifting Class does so why not use it...

  • Christoph Pojer

    Christoph Pojer November 5th, 2010 @ 08:29 PM

    • State changed from “new” to “wontfix”

    Arieh: defineProperty is in fact very useful and very powerful

    However, there is no possible way to bring compatibility for anything related to defineProperty, so a full Object.create function is impossible. If we bring standard functionality to MooTools (Array.map etc.) we usually try to implement the full standard (minus error and certain edge-case handling).

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Tags

Pages