JavaScript: 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.hasOwnProperty ( "Reflect" ) ) // true

Type of Reflect is object.

〔►see JavaScript: 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 JavaScript: Prototype and Inheritance〕 〔►see JavaScript: 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 JavaScript: Math Object〕 )

Reflect's methods typically duplicate operator behavior in function form, or provide a more strict/improved version of existing methods.

〔►see JavaScript: Object Object

〔►see JavaScript: Function Object

Properties


Reflect.get

〔►see JavaScript: Reflect.get

Reflect.set

〔►see JavaScript: Reflect.set

Reflect.has

〔►see JavaScript: Reflect.has


Reflect.defineProperty

〔►see JavaScript: Reflect.defineProperty

Reflect.deleteProperty

〔►see JavaScript: Reflect.deleteProperty

Reflect.getOwnPropertyDescriptor

〔►see JavaScript: Reflect.getOwnPropertyDescriptor


Reflect.ownKeys

〔►see JavaScript: Reflect.ownKeys

Reflect.enumerate

〔►see JavaScript: Reflect.enumerate


Reflect.getPrototypeOf

〔►see JavaScript: Reflect.getPrototypeOf

Reflect.setPrototypeOf

〔►see JavaScript: Reflect.setPrototypeOf


Reflect.isExtensible

〔►see JavaScript: Reflect.isExtensible

Reflect.preventExtensions

〔►see JavaScript: Reflect.preventExtensions

Reflect.apply

〔►see JavaScript: Reflect.apply

Reflect.construct

〔►see JavaScript: Reflect.construct

Reference

ECMAScript 2015 §Reflection#sec-reflect-object

Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.