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@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > -- Dr. Axel Rauschmayer a...@rauschma.de home: rauschma.de twitter: twitter.com/rauschma blog: 2ality.com
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss