CodesJava

Easy learning with example program codes

JavaScript ownKeys() method

The Javascript handler ownKeys() method gives an enum object in return.

Syntax:

ownKeys: function(target)

Parameters:
target: It represents the target object.

Return:
An enumerable object.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
var handler = new Proxy({}, {  
ownKeys: function(a) {  
document.writeln(" My favourite fruits are: ");  
return ['apple', 'mango', 'and orange.'];  
}});  
document.writeln(Object.getOwnPropertyNames(handler));   
</script>
</body>
</html>

Output:

My favourite fruits are: apple,mango,and orange.
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status