JS.next

JavaScriptの最新実装情報を追うブログ

Object.getOwnPropertyDescriptorsが実装された

概要

対象のオブジェクトがもつ全てのPropertyDescriptorsを得られる関数が実装された。


以下の時

obj = {
    name: 42,
    [ Symbol( 'foo' ) ]: 56
}

これまでは

Object.getOwnPropertyDescriptor( obj, 'name' ) 

のように1つずつしか得られなかったが

これからはgetOwnPropertyDescriptorsの方を呼ぶことで

Object.getOwnPropertyDescriptors( obj )
// ->
{
    name1: {
        value: 42,
        writable: true,
        enumerable: true,
        configurable: true
    },
    Symbol( foo ): {
        value: 56,
        writable: true,
        enumerable: true,
        configurable: true
    }
}

のように全てのプロパティの名前とディスクリプタを含んだオブジェクトの形で得ることができる。


実装されるバージョン

V8 4.10.1