3 ms·
> The difference is that JS has no binding ... just functions that take an argument named `this` Associating a name with a value is precisely what binding is.
by groovy2shoes 10y ago
> The difference is that JS has no binding ... just functions that take an argument named `this`
Associating a name with a value is precisely what binding is.
Frankly, though, I don't understand this comment at all. Care to clarify for me?
- prodigal_erik 10y agoIn Python b = foo.bar b() correctly invokes the bar method of the foo object. In JavaScript, you have to write let b = foo.bar.bind(foo) because foo.bar gives you a function (not a method) that doesn't remember which object it came from.
- groovy2shoes 10y agoI'm aware of what you have to write in JS, and I'd argue that that's the behavior that's to be expected. I'm actually more surprised by Python's behavior here. Lua works the same way JS does, as does Common Lisp.