What will be the output of the following JavaScript code? [code] const object1 = {}; Object.defineProperties(object1, { property1:

Tam ca

New member
What will be the output of the following JavaScript code?
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.
 

Tìm kiếm

Back
Top