As already mentioned in the comments, the way you present it, this is not possible, it only works if the function foo is called from a function, which then of course has to be a different function for each script, then you can use
console.log(arguments.callee.caller.name)
That will give you the name of the function that called your function foo.
Edit: and really, if it's important to know from where the script was called, just use an argument, like function foo(caller){, which indicates how the function was called, that's much safer than relying on the arguments.callee.caller thing.