Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Objects</h1>
<h2>The Object.preventExtensions() Method</h2>
<p id="demo"></p>
<script>
const fruits = ["Banana", "Orange", "Apple", "Mango"];
Object.preventExtensions(fruits);
// Test Error
let text = "";
try {
  fruits.push("Kiwi");
}
catch (err) {
  text = err;
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>