I doubt it is possible, but I would like to do it.
I would like to write a function that introduces new variables into the scope of its caller.
The goal is to do something like this:
(function() {
var x = {a: 5, b:6};
console.log(typeof a, typeof b);
magicImport(x);
console.log(a, b);
})();
console.log(typeof a, typeof b);
If magicImport(x)doing something like
eval("var a = x.a; var b = x.b;");
that does not really help, since the area aand bwould be bounded inside magicImport.
And of course,
eval("a = x.a; b = x.b;");
not suitable as this will change the global object.
Is there a way for evalcode in a higher area?
EDIT . The goal, if not clear, is to create a function that can import the contents of the namespace without polluting the global area and without the need to place these imported objects in a new container object.