DUET PG Score Card 2021
NHAI Recruitment 2021
Bihar Board 12th Dummy Admit Card 2022
RBI Assistant Notification 2021
Jee Advanced 2021 Result
NIACL Assistant Recruitment 2021
SBI PO Online Form 2021

Find Output – I Suppose that you have the following code written inside your app.js file

Find Output – I

let obj1 = {
 x: 10,
 y: 20
let obj2 = obj1;
obj1.x = 30; // manipulating the key of obj1
console.log(obj1.x, obj2.x);
node app 
  1. 30 10
  2. 10 10
  3. 30 30 Correct
  4. 30 undefined

Feedback: This option is the correct choice. The key named x is initially assigned the value 10. Then, you pass by reference the key-value pairs stored in obj1 to obj2.

obj1.x = 30;

you change the value of key named x to 30 inside obj1. Since obj2 refers to obj1, this change gets reflected in obj2 too. Hence, the value that will be associated with the key named x in obj2 will be changed to 30. Hence, the output 30 30 will be logged on to the console.

Leave a Comment