CodesJava

Easy learning with example program codes

Object.seal() JavaScript

The JavaScript Object seal() method prevents any new properties from being added and marks all existing properties as non-configurable.

Syntax:

Object.seal(object) 

Parameters:
seal: It represents the object which have to be sealed.

Return:
Sealed Object.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
const a = { prop: 'HELLO'};  
const b = Object.seal(a);  
b.prop = 'WORLD';  
document.write(b.prop);  
</script>
</body>
</html>

Output:

WORLD
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status