Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following JavaScript code?
const object1 = {};
Object.defineProperties(object1,
{
property1:
{
value: 10
}
});
console.log(object1.property1);

What will be the output of the following JavaScript code?
const object1 = {};
Object.defineProperties(object1,
{
property1:
{
value: 10
}
});
console.log(object1.property1);
a) 0
b) 10
c) undefined
d) error

Answer: b
Explanation: Object.defineProperties() is a predefined function in the object library of javascript. The Object.defineProperties() method defines new or modifies existing properties directly on an object and returns the object.

Join The Discussion