// オブジェクトのプロパティ記述子配列を取得します。 const GetObjectOwnPropertyDescArray = object => Object.entries(Object.getOwnPropertyDescriptors(window)) // プロパティ記述子配列からデータ記述子を抜き出します。 const FilterOwnPropertyDescArrayData = descs => descs.filter(desc => !!desc.value); // プロパティ記述子配列からアクセサー記述子を抜き出します。 const FilterOwnPropertyDescArrayAccessor = descs => descs.filter(desc => desc.get || desc.set);
プロパティ記述子(Property descriptor)、データ記述子(Data descriptor)、アクセサー記述子(Qccessor descriptor)の名称はObject.defineProperty() - MDNに従っています。
// windowオブジェクトのプロパティ記述子配列を取得する。 const windowPropDescs = GetObjectOwnPropertyDescArray(window); // 書き込み不可/列挙不可プロパティのプロパティ記述子配列取得を取得する。 const windowNonwritablePropDescs = windowPropDescs.filter(desc => !desc.writable); const windowNonenumerablePropDescs = windowPropDescs.filter(desc => !desc.enumerable); console.log(windowNonwritablePropDescs); console.log(windowNonenumerablePropDescs); // データ/アクセサーのプロパティ記述子配列を取得する。 const FilterOwnPropertyDescArrayData = descs => descs.filter(desc => !!desc.value); const FilterOwnPropertyDescArrayAccessor = descs => descs.filter(desc => desc.get || desc.set); console.log(FilterOwnPropertyDescArrayData(windowPropDescs)); console.log(FilterOwnPropertyDescArrayAccessor(windowPropDescs));