Я не могу правильно получить свойство, используя GetownPropertyDescriptorJavascript

Форум по Javascript
Anonymous
Я не могу правильно получить свойство, используя GetownPropertyDescriptor

Сообщение Anonymous »

Я не могу понять это. Мне нужно использовать специальный метод для моей цели - object.getownpropertydescriptor (). Это мой код: < /p>
function Album(title, artist, genre, year) {
this.title = prompt();
this.artist = prompt();
this.genre = prompt();
this.year = prompt();
}

let album1 = new Album()
for (let k in album1) {
if (album1.hasOwnProperty(key)) {
console.log("Property: " + key);
console.log(Object.getOwnPropertyDescriptors(album1, album1[key]))
console.log("...")
}
}
< /code>
Мне нужно получить данные, как это: < /p>
Property: title
value: Thriller
configurable: true
enumerable: true
writable: true
...
Property: artist
value: Michael Jackson
configurable: true
enumerable: true
writable: true
...
Property: genre
value: Pop
configurable: true
enumerable: true
writable: true
...
Property: year
value: 1982
configurable: true
enumerable: true
writable: true
...
< /code>
Теперь я получаю код, которым я не доволен. Я совсем не поступаю. Я сделал снимок экрана того, что мне удалось сделать до сих пор.
< /p>

Подробнее здесь: https://stackoverflow.com/questions/794 ... descriptor

Вернуться в «Javascript»