this
within a function is dynamically set at runtime:
var person = {
hello: function(thing) {
console.log(this, " says hello " + thing);
}
}
// the code:
person.hello("world");
// is similar to:
person.hello.call(person, "world");
Is there a way, after binding a function to an object, to retrieve that object from a reference to the bound function? For example:
var mysteryFunction = person.hello;
mysteryFunction.getMyRuntimeThis() // returns: person