I have created a function to call a named function. It works both in browser and in Node.js. I have created a gist (https://gist.github.com/netsi1964/3f19bd96f2d6e18bd818) which also contains a small test. The fingerprint of the function is: callFunction(scope, fn, args).
It sets the scope in the function to the specified scope, and defaults to window (in browser) and global (in Node.js).
To answer your original request you would use it like this:
callFunction(window, "foo",["test"])