Object.getOwnPropertyDescriptor() JavaScript JS

The Javascript Object getOwnPropertyDescriptor() method retrieves a property descriptor for the specified property of the specified object.

Syntax:

Object.getOwnPropertyDescriptor(object, property)

Parameters: object: It represents the object whose property descriptor has to be fetched.

Return: A property descriptor for the specified property.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
const obj = { prop: 56 }
const descript = Object.getOwnPropertyDescriptor(obj,'prop');
document.write(descript.enumerable + "<br>");
document.write(descript.value);
</script>
</body>
</html>
Please follow and like us:
Content Protection by DMCA.com