0 votes
in JavaScript by

Which one of the given options can be considered as the correct output for the following JavaScript code?

const obj1 =  

{  

    a:10,  

    b:15,  

    c:18  

};  

const obj2 =Object.assign({c:7, d:1}, obj1);  

console.log(obj2.c, obj2.d);  
 

a) Undefined

b) 18,1

c) 7,1

d) Error

1 Answer

0 votes
by

Answer: C

Reason: The "object.assign()" method mentioned in the above code, is used for copying the values and properties of one object to another. Here the objects are assigned and will be copied by the reference.

Related questions

0 votes
asked Mar 22, 2021 in JavaScript by Robindeniel
0 votes
asked Mar 23, 2021 in JavaScript by sharadyadav1986
...