CodesJava

Easy learning with example program codes

JavaScript getOwnPropertyDescriptor() method

The Javascript handler getOwnPropertyDescriptor() method traps for Object.getOwnPropertyDescriptor().

Syntax:

getOwnPropertyDescriptor: function(target, property)

Parameters:
target: It represents the target object.
property: It represents the property whose description should be retrieved.

Return:
An object or undefined.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
const handler = new Proxy({}, {  
getOwnPropertyDescriptor: function(a,b) {  
document.writeln('HELLO WORLD!');  
return Object.getOwnPropertyDescriptor(a,b);  
}});  
console.dir(Object.getOwnPropertyDescriptor(handler));   
</script>
</body>
</html>

Output:

HELLO WORLD!
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status