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:

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:

<!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>
Please follow and like us:
Content Protection by DMCA.com