Object.getOwnPropertyDescriptors() JavaScript JS

The Javascript Object getOwnPropertyDescriptors() method retrieves all own property descriptors of an object. It will return an empty object if there is no property associated with the Object.

Syntax:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Object.getOwnPropertyDescriptors(object)
Object.getOwnPropertyDescriptors(object)
Object.getOwnPropertyDescriptors(object)

Parameters:
object: It represents the object whose own property descriptors have to be fetched.

Return:
All own property descriptors of the specified object.

Example:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<body>
<script>
const obj = { prop: 56 }
const descript = Object.getOwnPropertyDescriptors(obj);
document.write(descript.prop.enumerable + "<br>");
document.write(descript.prop.value);
</script>
</body>
</html>
<!DOCTYPE html> <html> <body> <script> const obj = { prop: 56 } const descript = Object.getOwnPropertyDescriptors(obj); document.write(descript.prop.enumerable + "<br>"); document.write(descript.prop.value); </script> </body> </html>
<!DOCTYPE html>
<html>
<body>
<script>
const obj = { prop: 56 }
const descript = Object.getOwnPropertyDescriptors(obj);
document.write(descript.prop.enumerable + "<br>");
document.write(descript.prop.value);
</script>
</body>
</html>