JavaScript preventExtensions() method

The Javascript handler preventExtensions() method traps the Object.preventExtensions method. New properties can not be added to object when extensions are prevented.

Syntax:

preventExtensions: function(target)

Parameters:
target: It represents the target object.

Return:
Boolean.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
const handler = new Proxy({}, {  
  preventExtensions: function(a) {  
   Object.preventExtensions(a);  
	return !Object.isExtensible(a);  
  }});  
document.writeln('Value: ');   
document.writeln(Object.isExtensible(handler));   
</script>
</body>
</html>

Output:

Value: true
Please Share