.... python and c++ are modern and popular and they can't do the thing I said. You asked for an example and having been proven wrong you have just been insulting me
you can easily change the binding scope with a slight change in syntax.
Can you say more about what this means? I'm not familiar enough with Javascript and a quick Google search didn't seem to turn up anything directly relevant.
I've heard that "dynamic this" was one of the big mistakes in Javascript, and that it was corrected by introducing arrow functions in ES6, which always use "lexical this". Do you think that's a fair assesment?
I honestly haven't had to do a lot of javascript pre 2016 so I don't know if I can weigh in much. I would say I use the normal (non arrow) syntax more in my own code, but the ability to switch between them easily is nice
The thing is, I can foresee that using dynamic this makes stuff confusing and difficult to follow, so why use it at all? I'm not talking about the syntax differences between "classic" anonymous functions and arrow functions, but about the differences in scoping for this.
I am talking about this I use the dynamic this often. It really just depends man. What is cool I think is you don't have to have one or the other, or right any strange closures like var This = this to use the one you want anymore
I guess that in the context of Javascript, having dynamic this makes sense. It would be completely fucked in other languages that have OOP, where instance variables have public/private access modifiers.
View all comments
Show parent comment
2
u/Code_star Jun 25 '18
it has very easy to use anonymous functions where you can easily change the binding scope with a slight change in syntax.