From 05c65f7203ca8c5ae6f4501d399a76c94084c659 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Tue, 18 Aug 2020 08:57:37 +0300 Subject: [PATCH] Update javascript-this.md Fixes #8 --- blog_posts/javascript-this.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/blog_posts/javascript-this.md b/blog_posts/javascript-this.md index aa32281a1..940242783 100644 --- a/blog_posts/javascript-this.md +++ b/blog_posts/javascript-this.md @@ -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.