Object.getOwnPropertyDescriptors

Axel Rauschmayer axel at rauschma.de
Fri Nov 11 11:47:42 PST 2011


It has already been proposed, look here: http://wiki.ecmascript.org/doku.php?id=strawman:extended_object_api

On Nov 11, 2011, at 20:30 , Xavier MONTILLET wrote:

> 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 at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111111/e0fa4b8c/attachment-0001.html>


More information about the es-discuss mailing list