<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript strict mode prevent to extend object properties</title>
</head>
<body>
<script type="text/javascript">
// Press F12 - View result on Console Panel
var obj = {};
Object.defineProperties(obj, {
"pro1": {
value: 10
},
});
console.log( obj ); // pro1: 10
obj.name = "Opal Kole"; // works!, extended
console.log( obj ); // name: "Opal Kole", pro1: 10
Object.preventExtensions( obj );
obj.address = "63 street Ct."; // not works!, prevent to extend
console.log( obj ); // name: "Opal Kole", pro1: 10
</script>
</body>
</html>