I found this answer: How to modify "this" in javascript
But I did not like it. Surely there must be a way to somehow modify this
?
See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures
Simple types (except objects and arrays) is immutable. You can't modify it and save in source variable.
function foo() {
this.val+=10;
}
a=function(obj) {
a=foo.bind(obj);
}
But you can wrap it into object. See: http://jsfiddle.net/5dhm8fsn/