Module3: What is the call Method?

This commit is contained in:
jason.zhu 2021-05-12 13:36:32 +10:00
parent e6874571ca
commit 0c245858e6

16
app.js
View File

@ -1,11 +1,7 @@
let message = {
name: 'John',
regularFunction: function() {
console.log(this)
console.log('Hello ' + this.name);
},
arrowFunction: () => console.log(this)
}
let person1 = {name: 'John', age: 22};
let person2 = {name: 'Mary', age: 26};
message.regularFunction();
message.arrowFunction(); //
let sayHi = function() {
console.log('Hi, ' + this.name);
};
sayHi.call(person1);