Hacker News new | ask | show | jobs
by aryehof 3139 days ago
Does JavaScript have some special definitions for delegation and dynamic dispatch? The definitions provided in the article appear to particularly relate them to inheritance - which is not the traditional definition applied to either term in object-orientation?
1 comments

I think that the article is actually correct, because the reason why in other - mostly static, and better designed dynamic -languages, you knew that member functions were bound to the object being called is because that is how the functions were actually handled by that language's runtime. There is no such assumption in JS, so where in C# you explicitly design a delegate, the reverse is true here. You need to explicitly bind the function or declare the function as a property with an arrow function and capture the execution context.