I am facing an issue with my application that utilizes the v8 javascript engine. I have functions added to namespace objects which execute lines of code from the database. The challenge is to make sure that these functions do not require 'this' to be added before every function call. Below is an example showcasing my problem:
var obj = {};
obj.method = function(a) { return a; }
obj.executor = function() { return method(5); }
obj.executor()
ReferenceError: method is not defined
var caller = function() { return method(5); }
caller.call(obj)
ReferenceError: method is not defined
As seen above, neither method enables me to call 'method' without adding 'this' before it. Is there any way to execute a function in such a manner that 'this' does not need to be appended?
EDIT
This approach worked in a previous version of the v8 engine, but it appears to be unsupported in the latest version.