CodesJava

Easy learning with example program codes

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 follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status