Reflect.deleteProperty()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.

Reflect.deleteProperty() 정적 메서드는 속성을 제거할 수 있습니다. delete 연산자의 함수판이라고 할 수 있습니다.

시도해보기

const object1 = {
  property1: 42,
};

Reflect.deleteProperty(object1, "property1");

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

const array1 = [1, 2, 3, 4, 5];
Reflect.deleteProperty(array1, "3");

console.log(array1);
// Expected output: Array [1, 2, 3, undefined, 5]

구문

js
Reflect.deleteProperty(target, propertyKey);

매개변수

target

속성을 제거할 대상 객체.

propertyKey

제거할 속성의 이름.

반환 값

속성이 성공적으로 제거됐는지 나타내는 Boolean.

Exceptions

targetObject가 아니면 TypeError.

설명

Reflect.deleteProperty 메서드는 객체의 속성을 제거할 수 있습니다. 반환값은 속성의 제거 성공 여부를 나타내는 Boolean입니다. 비엄격 모드의 delete 연산자와 거의 동일합니다.

예제

Reflect.deleteProperty() 사용하기

js
var obj = { x: 1, y: 2 };
Reflect.deleteProperty(obj, "x"); // true
obj; // { y: 2 }

var arr = [1, 2, 3, 4, 5];
Reflect.deleteProperty(arr, "3"); // true
arr; // [1, 2, 3, , 5]

// 주어진 속성이 존재하지 않으면 true 반환
Reflect.deleteProperty({}, "foo"); // true

// 주어진 속성이 설정 불가능하면 false 반환
Reflect.deleteProperty(Object.freeze({ foo: 1 }), "foo"); // false

명세

Specification
ECMAScript® 2025 Language Specification
# sec-reflect.deleteproperty

브라우저 호환성

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
deleteProperty

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

같이 보기