What is the apply Method?
parent
0c245858e6
commit
6a0a672e35
14
app.js
14
app.js
|
@ -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');
|
Loading…
Reference in New Issue