On Fri, Jul 25, 2014 at 11:52 AM, Michaël Rouges
<[email protected]> wrote:
> Hi all,
>
> There is any plan around un functionnality like the "use" keyword, in PHP.
PHP's use() syntax is because PHP doesn't have actual lexical
closures; it's a hack around the lack.
> Why something like that? Because, in JS, there is no way to inject some
> variables,
> without touch the this object known in a function.
"Injecting variables into a function" is typically done by passing arguments.
> 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');`
This is functionally identical to:
fn = function(value) { return function() { console.log(value); };
fn("hello")
Using the Function constructor here doesn't seem to offer anything at
all over just writing a normal function. Am I missing something?
~TJ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss