revive let blocks

Bucaran jbucaran at me.com
Thu Jun 18 12:59:29 UTC 2015


I see what you mean.

I always try to favor functional-style JavaScript (creating a big expression composed
of several functions, both as arguments or declared somewhere, using recursion 
instead of keeping state, not using control structures, no variables, etc), hence my 
suggestion.

Performance wise you are (very probably) right, but I am willing to pay the tradeoff and 
live the future now, or whenever I can :)

Another idea I find fun it’s binding this to an object with my data:

```js
function f () {
}

f.call({a:2, b, c})
```


> On Jun 18, 2015, at 9:34 PM, Kyle Simpson <getify at gmail.com> wrote:
> 
>> (function (a, b, c) {
>> 
>> }(2))
> 
> The main disadvantage of that style over the one I'm advocating for is that it visually separates the variable declaration (`a`) from its value initialization (`2`). If there's 5, 10, or more lines of code in between them, it makes it much harder to figure out the initial state of variables as they enter a "block".
> 
> Also, obviously, a function call is more heavy weight (performance wise) than a block with scoped declarations.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss



More information about the es-discuss mailing list