The JavaScript Reflect.get() method gives the property of an object as a function.
Syntax:
Reflect.get(target, propertyKey[, receiver])
Parameters:
target: It represents the object whose property have to be get.
propertyKey: It represents the name of the property to be get.
receiver: It represents the value of this provided for the call to object if a getter is encountered. It is an optional parameter.
Return:
The value of the specified property.
Example 1:
<!DOCTYPE html> <html> <body> <script> var n = [1100, 2200, 3100, 4100, 5100]; document.write(Reflect.get(n, '1')); </script> </body> </html>
Example 2:
<!DOCTYPE html> <html> <body> <script> const object1 = { num1: 1, num2: 2 }; document.write(Reflect.get(object1, 'num1')); document.write("</br>"); var array1 = ['zero', 'one']; document.write(Reflect.get(array1, 1)); </script> </body> </html>