Module3: What is the call Method?
This commit is contained in:
parent
e6874571ca
commit
0c245858e6
16
app.js
16
app.js
@ -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);
|
Loading…
x
Reference in New Issue
Block a user