What is the apply Method?

This commit is contained in:
jason.zhu 2021-05-12 13:48:15 +10:00
parent 0c245858e6
commit 6a0a672e35

14
app.js
View File

@ -1,7 +1,7 @@
let person1 = {name: 'John', age: 22}; function introduction(name, profession) {
let person2 = {name: 'Mary', age: 26}; console.log('My name is ' + name + ' and I am a ' + profession + '.');
console.log(this);
let sayHi = function() { }
console.log('Hi, ' + this.name); introduction('John', 'student');
}; introduction.apply(undefined, ['Mary', 'Lawyer']);
sayHi.call(person1); introduction.call(undefined, 'James', 'artiest');