On Fri, Dec 21, 2012 at 12:53 AM, Kevin Newman <capta...@unfocus.com> wrote:

> I wonder if you could use the second argument of Object.create to reduce
> the number of times Object.defineProperties appears in the source (and if
> it would matter at all).
>
> // Example where we create an object with a couple of sample properties.
> // (Note that the second parameter maps keys to *property descriptors*.)
> o = Object.create(Object.**prototype, {
>   // foo is a regular "value property"
>   foo: { writable:true, configurable:true, value: "hello" },
>   // bar is a getter-and-setter (accessor) property
>   bar: {
>     configurable: false,
>     get: function() { return 10 },
>     set: function(value) { console.log("Setting `o.bar` to", value) }
> }})
>
>
> Kevin N.
>
>
Yes, completely forgot about that.
May really make the defineClass() code even more concise--I'll have a go on
this.
I'd wouldn't expect a performance impact, though. As mentioned before,
property structure set-up is only done only once for each class.

-Frank-

Reply via email to