pluralsight-js-functions/app.js

11 lines
242 B
JavaScript
Raw Normal View History

2021-05-12 17:02:11 +10:00
let person1 = {
name: 'Mary',
getName: function(){
return this.name;
}
};
let person2 = {
name: 'John'
};
let getNameCopy = person1.getName.bind(person2); // won't change context of function
console.log(getNameCopy());