Question 11
Consider the following JavaScript code snippet:
var globalScore = 25;
const player1 = { score: 150, getScore: function() { return this.score; }, displayScore: function(bonus) { return this.score + (bonus || 0); }};
const player2 = { score: 200 };const player3 = { score: 75 };
const method1 = player1.getScore;const method2 = player1.getScore.bind(player2);const method3 = player1.displayScore.bind(player3);
console.log(method1());console.log(method2());console.log(method3(50));console.log(method3.call(player1, 25));What will be the output of the above JavaScript code?
undefined, 200, 125, 175
25, 200, 125, 175
150, 200, 125, 100
25, 200, 125, 100
undefined, 200, 125, 100