-
-
Save bernar83/c128beed42015440fa7094bfe78712bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setName(name) { | |
this.name = name; | |
} | |
const person1 = { | |
setName: setName | |
}; | |
const person2 = {}; | |
person1.setName('bob'); | |
console.log(person1.name); // "bob" | |
person1.setName.call(person2, 'bill'); | |
console.log(person2.name); // "bill" | |
const dave = new person1.setName('dave'); | |
console.log(dave.name); // "dave" | |
console.log(person1.name); // "bob" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment