February 2018
Intermediate to advanced
298 pages
8h 22m
English
The Reflect.get() method is used to retrieve the value of an object's property. The first argument is the object and the second argument is the property name. If the property is an accessor property, then we can provide a third argument, which will be the value of this inside the get function.
Here is a code example that demonstrates how to use the Reflect.get() method:
var obj = { __name__: "Eden" };Reflect.defineProperty(obj, "name", { get: function(){ return this.__name__; } }); console.log(obj.name); //Output "Eden" var name = Reflect.get(obj, "name", {__name__: "John"}); console.log(name); //Output "John"
Read now
Unlock full access