JS: Reflect Object

By Xah Lee. Date: . Last updated: .

New in ES2015.

Reflect is the value of the property key "Reflect" of the global object.

console.log ( window["Reflect"] === Reflect ); // true

Type of Reflect is object.

[see JS: Data Types]

// type of Reflect
console.log ( typeof Reflect === "object" ); // true
console.log ( Object.prototype.toString.call(Reflect) === "[object Object]" ) // true

The parent of Reflect is Object.prototype. [see JS: Prototype and Inheritance] [see JS: Object.prototype]

console.log ( Reflect.getPrototypeOf ( Reflect ) === Object.prototype); // true

Purpose of Reflect

The Reflect object is used as namespace to host a group of static functions. (like the Math object. [see JS: Math Object] )

Reflect's methods typically:

[see JS: Object Object]

[see JS: Function Object]

Properties


Reflect.get

[see JS: Reflect.get]

Reflect.set

[see JS: Reflect.set]

Reflect.has

[see JS: Reflect.has]


Reflect.defineProperty

[see JS: Reflect.defineProperty]

Reflect.deleteProperty

[see JS: Reflect.deleteProperty]

Reflect.getOwnPropertyDescriptor

[see JS: Reflect.getOwnPropertyDescriptor]


Reflect.ownKeys

[see JS: Reflect.ownKeys]

Reflect.enumerate

[see JS: Reflect.enumerate]


Reflect.getPrototypeOf

[see JS: Reflect.getPrototypeOf]

Reflect.setPrototypeOf

[see JS: Reflect.setPrototypeOf]


Reflect.isExtensible

[see JS: Reflect.isExtensible]

Reflect.preventExtensions

[see JS: Reflect.preventExtensions]

Reflect.apply

[see JS: Reflect.apply]

Reflect.construct

[see JS: Reflect.construct]

Reference

ECMAScript 2015 §Reflection#sec-reflect-object

Liket it? Put $1 at patreon.

Or, Buy JavaScript in Depth