Closed
Description
I think there might not be a way round this. I'm trying to insert variables from another scope into the current scope as local variables like so:
var vars = { a: 1, b: 2} function mixin() { for(var i in vars) eval("var " + i + "=" + vars[i]) } (function() { mixin() console.log(a) })()
Obviously this doesn't work since "eval" is outside the closure. But there doesn't seem to be a way to reference the current lexical scope. Even mixin.call(this) wouldn't work.
As I said above, I'm not sure there's an easy round this - even for Coffee, but I'd be interested in all your ideas.
Cheers
J