MCQ Single Best Answer Easy

QWhat would the following JavaScript code produce?
const object1 = {};  
Object.defineProperties(object1,
{  
  	property1: 
        {  
             value: 10 
        }  
 });  
console.log(object1.property1);

ID: #5000 Javascript Classes MCQ 187 views
Question Info
#5000Q ID
EasyDifficulty
Javascript Classes MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • B 10
  • C undefined
  • D Error
Correct Answer: Option B

Explanation

The Object.defineProperties() method is a predefined function in the object library of JavaScript that is used to define new properties or modify existing properties on an object. It returns the object.
The Object.defineProperties() method takes an object as its first argument and a property descriptor object as its second argument. The property descriptor object can specify the characteristics of one or more properties to be added to or modified on the object.

Share This Question

Challenge a friend or share with your study group.