class Fruits {
constructor(name, color){
this.name = name;
this.color = color;
}
}
let apple = new Fruits("apple", "red");
//속성을 찾을 객체와 프로퍼티 이름을 받는다
console.log(Object.getOwnPropertyDescriptor(apple, "color")); //{ value: 'red', writable: true, enumerable: true, configurable: true }
//모든 속성의 프로퍼티 디스크립터 객체를 리턴
console.log(Object.getOwnPropertyDescriptors(apple));
// {
// name: {
// value: 'apple',
// writable: true,
// enumerable: true,
// configurable: true
// },
// color: {
// value: 'red',
// writable: true,
// enumerable: true,
// configurable: true
// }
// }
출처
이웅모, 모던 자바스크립트 Deep Dive(2021)