Question 8
Consider the following JavaScript code to answer the below question:
const grandParent = { username: 'GrandParent', getName: function () { return this.username; }, parent: { username: 'Parent', getName: function () { return this.username; }, child: { username: 'Child', getNameArrow: () => { return this.username; }, getNameFunc: function () { return this.username;
} } }};
console.log("A: " + grandParent.getName());console.log("B: " + grandParent.parent.getName());console.log("C: " + grandParent.parent.child.getNameFunc());console.log("D: " + grandParent.parent.child.getNameArrow());What will be the result of all the console.log after execution of the above code?