JavaScript get() method

The Javascript handler get() method traps for getting a property value.

Syntax:

get: function(target, property, receiver)

Parameters: target: It represents the target object. property: It represents the property to be obtained. receiver: It represents the proxy or an object that is inherited from the proxy.

Return: Any value.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
var handler = {"Height": 50}
var height = new Proxy(handler,{
get: function(a,b) {
return a[b] + 20
}})
for(var data in height) {
document.write(data +":")
document.write(height[data])
}
</script>
</body>
</html>
Please follow and like us:
Content Protection by DMCA.com