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 that 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>
Please follow and like us:
Content Protection by DMCA.com