[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set [Back]  [Original]

Reflect.set() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Reflect.set()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2016 9.

Reflect.set() .

In this article

const object1 = {};
Reflect.set(object1, "property1", 42);

console.log(object1.property1);
// Expected output: 42

const array1 = ["duck", "duck", "duck"];
Reflect.set(array1, 2, "goose");

console.log(array1[2]);
// Expected output: "goose"

js
Reflect.set(target, propertyKey, value[, receiver])

target

.

propertyKey

.

value

.

receiver Optional

, this .

Boolean.

target Object TypeError.

Reflect.set() . , .

Reflect.set()

js
// Object
var obj = {};
Reflect.set(obj, "prop", "value"); // true
obj.prop; // "value"

// Array
var arr = ["duck", "duck", "duck"];
Reflect.set(arr, 2, "goose"); // true
arr[2]; // "goose"

//  
Reflect.set(arr, "length", 1); // true
arr; // ["duck"];

//        "undefined",  undefined
var obj = {};
Reflect.set(obj); // true
Reflect.getOwnPropertyDescriptor(obj, "undefined");
// { value: undefined, writable: true, enumerable: true, configurable: true }

Specification
ECMAScript 2027 LanguageSpecification
# sec-reflect.set


Web Proxy Viewer  |  New URL  |  Original Page