What will be the output for the following question (Copying in JavaScript)?
@Lakshya Thakur
let saiyan = {
name: "Vegeta",
chiBlasts: {
low: "Big bang attack",
med: "Gallic gun",
high: "Final flash",
},
};
let anotherSaiyan = { ...saiyan };
anotherSaiyan.name = "Goku";
anotherSaiyan.chiBlasts.high = "Spirit Bomb";
let sonOfSaiyan = Object.assign({}, saiyan);
sonOfSaiyan.name = "Trunks";
sonOfSaiyan.chiBlasts.high = "Finish Buster";
let sonOfAnotherSaiyan = JSON.parse(JSON.stringify(anotherSaiyan));
sonOfAnotherSaiyan.name = "Gohan";
sonOfAnotherSaiyan.chiBlasts.high = "Kamehameha";
console.log(
saiyan.name,
anotherSaiyan.name,
sonOfSaiyan.name,
sonOfAnotherSaiyan.name
);
console.log(
saiyan.chiBlasts.high,
anotherSaiyan.chiBlasts.high,
sonOfSaiyan.chiBlasts.high,
sonOfAnotherSaiyan.chiBlasts.high
);
Option 1
Vegeta Goku Trunks Gohan Final flash Spirit Bomb Finish Buster Kamehameha
Option 2
Vegeta Goku Trunks Gohan Spirit Bomb Spirit Bomb Finish Buster Kamehameha
Option 3
Vegeta Goku Trunks Gohan Finish Buster Finish Buster Finish Buster Kamehameha
Option 4
Vegeta Goku Trunks Gohan Final flash Finish Buster Finish Buster Kamehameha
Option 5
Vegeta Goku Trunks Gohan Kamehameha Kamehameha Kamehameha Kamehameha
Option 6
Vegeta Goku Trunks Gohan Finish Buster Finish Buster Finish Buster Finish Buster