tc39 / proposal-bind-operator

This-Binding Syntax for ECMAScript
1.75k stars 30 forks source link

Provide a binary example without calling #12

Closed XeCycle closed 8 years ago

XeCycle commented 9 years ago

This confused me at first, that obj::fn(arg) is equivalent to (obj::fn)(arg), not obj::(fn(arg)). Intuitively narrated, the :: operator has higher precedence than function call operator, and obj::fn is a valid expression on its own, similar to obj.fn. Without such an example it looks to me like the binary form requires the function to be called in-place. Something like the following will work:

var boundFn = obj::fn;
boundFn(arg);