I have following javaScript \"class\":
A = (function() {
a = function() { eval(...) };
A.prototype.b = function(arg1, arg2) { /* do something... */};
}
Even though, eval.call and eval.apply do not force the context to be passed in correctly, you can use a closure to force eval to execute in the required context as mentioned in the answers of @Campbeln and @user3751385
This is not possible. Eval is called only in the local context(is used directly) or in the global context (even if you use eval.call).
For example,
a = {};
eval.call(a, "console.log(this);"); //prints out window, not a
For more information, look at this great article here