CodesJava

Easy learning with example program codes

Object.defineProperties() JavaScript JS

The Javascript Object defineProperties() method is used to add or modify multiple object properties.

Syntax:

Object.defineProperties(object, properties) 

Parameters:
object: It represents the object on which multiple properties have to be added or modified.
properties: It represents the properties which have to be added or modified.

Return:
Modified object.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
const obj = {};  
Object.defineProperties(obj, { prop1: {value: 56},  
prop2: {value: 65}});  
document.write(obj.prop1 + "<br>")
document.write(obj.prop2);   
</script>
</body>
</html>

Output:

56
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status