• The timings are for around 10 calls. I'm sure its the same function. I rewrote the code so that apply or call are not required, though when I place them in there it slows down a lot. I'm not sure what you mean with the .foo? I have printed both "this"-es and they are the same with and without. The reason I needed the apply in the first place was that the methods were in a seperate object:

    agent.RPCfunctions[message.content.method].call(agent,message.content.params,callback);
    

    Agent has a number of functions and properties.. not necessarily huge, though shouldnt apply mearly change a pointer to the this object? The callback function contains a reference to the agent as well:

    var callback = function (data) {agent._send(message.origin, data, agentId, message.content.id);};
    

    If I empty the callback

    var callback = function (data) {};
    

    the difference in execution speed drops dramatically. Does apply or call copy the arguments including their references somehow?

About

Avatar for Alex @Alex started