| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2016 9.
Reflect.set() .
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"
Reflect.set(target, propertyKey, value[, receiver])
target.
propertyKey.
value.
receiver Optional , this .
Reflect.set() // 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 |
This page was last modified on 2025 2 11 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |