I am not sure I understand your problem but AFAIK php introduced "use" to simulate JavaScript implicit outer scope access instead of the explicit global context php is (in)famous for, it comes quite as a surprise you are asking JS to simulate PHP here :-)
`var test, fn; fn = new Function('value', 'return function (){console.log(value);}'); fn('hello');` I don't see why would you pass through Function instead of just wrapping that function. ```js var fn = (function(floatNum, genericString){ return function (anotherArg) { console.log(floatNum, genericString, anotherArg); }; }( // here the equivalent of your "use" Math.random(), 'whatever' )); fn('yo'.sup()); ``` will produce something like: 0.3651656119618565, whatever, <sup>yo</sup> Best Regards On Fri, Jul 25, 2014 at 11:52 AM, Michaël Rouges <michael.rou...@gmail.com> wrote: > Hi all, > > There is any plan around un functionnality like the "use" keyword, in PHP. > > Why something like that? Because, in JS, there is no way to inject some > variables, > without touch the this object known in a function. > > The lone possible way is with ownmade functions, in the same context, by : > > `var test, > fn; > > fn = new Function('value', 'return function (){console.log(value);}'); > > fn('hello');` > > Really boring to share some private variables... > > > > Michaël Rouges - https://github.com/Lcfvs - @Lcfvs > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss