Hi,

I think adding Object.getOwnPropertyDescriptors would be great.

It could be implemented like this:

Object.getOwnPropertyDescriptors = function ( object ) {
    var propertiesDescriptor = { };
    Object.getOwnPropertyNames( object ).forEach( function ( key ) {
        propertiesDescriptor[ key ] = Object.getOwnPropertyDescriptor(
object, key );
    } );
    return propertiesDescriptor;
}

And here are some usecases that would be much longer to write without it:

Function.prototype.inherits = function ( Parent ) {
    this.prototype = Object.create( Parent.prototype,
Object.getOwnPropertyDescriptors( this.prototype ) );
    return this;
};

Object.prototype.clone = function ( ) {
    return Object.create( Object.getPrototypeOf( this ),
Object.getOwnPropertyDescriptors( this ) );
};
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to