Add .call example

This commit is contained in:
Andrew Morris
2022-04-20 14:55:37 +10:00
parent b041614204
commit 682feefd41

View File

@@ -128,3 +128,15 @@ function eg7() {
console.log(f); // 3
}
function eg8() {
let x = {};
function addFoo() {
this.foo = 'bar';
}
addFoo.call(x);
console.log(x.foo); // 'bar'
}