[PROPOSAL] "use" keyword

Andrea Giammarchi andrea.giammarchi at gmail.com
Fri Jul 25 12:36:43 PDT 2014

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 = new Function('value', 'return function (){console.log(value);}');


I don't see why would you pass through Function instead of just wrapping
that function.

var fn = (function(floatNum, genericString){
  return function (anotherArg) {
    console.log(floatNum, genericString, anotherArg);
  // here the equivalent of your "use"


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.rouges at gmail.com>

> 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 at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140725/c32d38e3/attachment.html>

More information about the es-discuss mailing list