On 2 May 2012 17:58, Glidos <[email protected]> wrote:
> I need to run scripts that use a convention of "this" refering to a
> specific, otherwise-unnamed object. Is there a way to make v8 handle
> that convention?
>
> So far the only work-around I can think of is to provide the global
> template with an explicit property to refer to the object
> (implicitThisObj say). Then I'd alter the incoming  <script-text> to
> be
>
> implicitThisObj.tempFunc = function() { <script-text> };
> implicitThisObj.tempFunc();
>
> but that's a bit messy. Anyone know a better way?

Rewrite to:

(function() { <script-text> }).call(implicitThisObj)

That's the easiest way. The global object is quite special, and cannot
just be replaced it with a random object.

/Andreas

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to