I often need to pass methods from objects into other objects. However I usually want the method to be attached to the original object (by attached I mean 'this' should refer to the original object). I know a few ways to do this:
a) In the object constructor: ObjectA = function() { var that = this; var method = function(a,b,c) { that.abc = a+b+c }}
b) In objectA which has been passed objectB: objectB.assign(function(a,b,c) { that.method(a,b,c) })
c) Outside both objects: objectB.assign(function(a,b,c) { objectA.method(a,b,c) })
I want to know if there is a simpler way to pass methods attached to their original objects.