<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript strict mode prevent to deletion object properties</title>
</head>
<body>
<script type="text/javascript">
// Press F12 - View result on Console Panel
var obj = {};
Object.defineProperties(obj, {
"pro1": {
value: 10,
configurable: true // default false
},
"pro2": {
value: "Hello World!",
configurable: false
}
});
console.log( obj ); // pro1: 10, pro2: "Hello World!"
delete obj.pro1; // works!, delete successfully
delete obj.pro2 ; // no works!, preven to deletion
console.log( obj ); // pro2: "Hello World!"
</script>
</body>
</html>