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.
La méthode statique Reflect.deleteProperty()
permet de supprimer des propriétés. Il agit comme l'opérateur delete
.
Exemple interactif
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]
Syntaxe
js
Reflect.deleteProperty(cible, cléPropriété);
Paramètres
cible
-
L'objet cible sur lequel on souhaite supprimer la propriété.
cléPropriété
-
Le nom de la propriété à supprimer.
Valeur de retour
Un booléen qui indique si la suppression de la propriété s'est bien passée.
Exceptions
Description
Exemples
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]
// Renvoie true si aucune propriété correspondante n'existe
Reflect.deleteProperty({}, "toto"); // true
// Renvoie false si une propriété n'est pas configurable
Reflect.deleteProperty(Object.freeze({ toto: 1 }), "toto"); // false
Spécifications
Specification |
---|
ECMAScript® 2025 Language Specification # sec-reflect.deleteproperty |
Compatibilité des navigateurs
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deleteProperty |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.