Update javascript-this.md

Fixes #8
This commit is contained in:
Angelos Chalaris
2020-08-18 08:57:37 +03:00
committed by GitHub
parent a14b59e4e0
commit 05c65f7203

View File

@ -62,7 +62,10 @@ const obj = {
} }
}; };
console.log(f()); // { foo } const myObj = Object.create(obj);
myObj.foo = 1;
console.log(myObj.f()); // { foo: 1 }
``` ```
Similarly, when used inside a constructor, `this` refers to the object being constructed. Similarly, when used inside a constructor, `this` refers to the object being constructed.