Unfinished Object Context Example in blog_posts/javascript-this.md
binlabs opened this issue · 1 comments
@Chalarangelo I'm not entirely sure what was meant to be done on lines 58-66 of javascript-this.md or else I'd have fixed it and opened a pull request, but it seems unfinished and doesn't return what it claims to.
The section in question is as follows:
Object context
When a function is called as a method of an object, this
refers to the object the method is called on. This applies to methods defined anywhere in the object's prototype chain (i.e. own and inherited methods).
const obj = {
f: function() {
return this;
}
};
console.log(f()); // { foo }
While claiming to return { foo }
, as currently written it returns ReferenceError: f is not defined
. However, even obj.f()
wouldn't return { foo }
, so I just imagine this example wasn't quite finished when this page was submitted and got overlooked.
Thanks for the heads up! This was fixed by updating the example. Updates will go live later today, when Netlify picks up the changes and rebuilds them.