Question from the Javascript test

Which of the following code will log the message 'baz'?

Hard

Either the following code:

function Player(name) {
    this.name = name;

    this.identity = function() {
        console.log('foo');
    }
}

Player.identity = function identity() {
    console.log('bar');
}

Player.prototype.identity = function identity() {
    console.log('baz');
}

let myObj = Player('qux'); // Create a player
myObj.identity();

What will be the logged message?

Author: Jean-marie CléryStatus: PublishedQuestion passed 2052 times
Edit
2
Community EvaluationsNo one has reviewed this question yet, be the first!