What I like about starting with the foo.call(x) example is that it immediately drains all of the magic.
There are no methods in javascript, functions do not belong to classes.
There are just functions which are invoked with some object as their 'this' context.
Having understood this, you can then move on to a.b(c) and show that it's equivalent to a.b.call(a, c).
I had not thought of it that way, I appreciate your reflection on the subject and I will consider it for future articles.
Thank you! :D
You are welcome. :)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
What I like about starting with the foo.call(x) example is that it immediately drains all of the magic.
There are no methods in javascript, functions do not belong to classes.
There are just functions which are invoked with some object as their 'this' context.
Having understood this, you can then move on to a.b(c) and show that it's equivalent to a.b.call(a, c).
I had not thought of it that way, I appreciate your reflection on the subject and I will consider it for future articles.
Thank you! :D
You are welcome. :)