JavaScript – Reflect

What is a reflect ?

Reflect is something coming back to you through reflection.

What is a reflect in programming language ?

Reflect is the ability to reflect the structure of the program.

This is simply as getting information back from the same old methods/fields/interfaces etc.

Javascript beginner course !!!

Click to Learn More about – Javascript online learning

What is a reflect in javascript ?

Reflect is an built-in javascript object provides methods for interceptable JavaScript operations.

Reflect is not a constructor, so object cannot be constructed.

All the properties and methods of reflect are static objects.

These methods are same like proxy handlers.

There are few methods in Javascript reflect listed below,

SnoMethod / FunctionDescription
1Reflect.apply()Reflect.apply() method calls a target function with arguments as specified by the args parameter.
2Reflect.construct()Reflect.construct() is new operator as a function, equivalent to calling new target(…args).
3Reflect.defineProperty()Reflect.defineProperty() is similar to Object.defineProperty().
4Reflect.deleteProperty()Reflect.deleteProperty() is the delete operator as a function.
5Reflect.get()Reflect.get() function that returns the value of properties.
6Reflect.getOwnPropertyDescriptor()Reflect.getOwnPropertyDescriptor() is similar to Object.getOwnPropertyDescriptor().
7Reflect.getPrototypeOf()Reflect.getPrototypeOf() method is same as Object.getPrototypeOf().
8Reflect.has()Reflect.has() method returns a boolean indicating whether an own or inherited property exists.
9Reflect.isExtensible()Reflect.isExtensible() is same as Object.isExtensible().
10Reflect.ownKeys()Reflect.ownKeys() returns an array of the target object’s own (not inherited) property keys.
11Reflect.preventExtensions()Reflect.preventExtensions() is similar to Object.preventExtensions(). Returns a Boolean.
12Reflect.set()Reflect.set() function that assigns values to properties.
13Reflect.setPrototypeOf()Reflect.setPrototypeOf() function that sets the prototype of an object.