5 ms·
bind was introduced in ES5 (and previously in most libraries) to fix this https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function
by locci 14y ago
bind was introduced in ES5 (and previously in most libraries) to fix this
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind https://developer.mozilla.org/en-US/docs/JavaScript/Referenc...
- huskyr 14y agoAnd trivially easy to shim for older browsers. I would really recommend using Function.prototype.bind instead of the 'var self = this' or library bind functions (such as $.proxy), it's just the way it should be written :)
- jessaustin 14y agoTo confirm my understanding, would the erroneous line from the comment above be rewritten like: button.onclick = obj.func.bind(obj); So un-DRY! It's almost admirable, how blatant a hack this is.