To all the haters: I'm using this technique to lazily initialize a variable that in some scenarios can be cached ahead of time. So sometimes you do: a = getCached() if (!a) cache(a = calc(x)) fn(x, a) And other times just fn(x)
-
-
Prikaži ovu nit
-
And now I can define fn like function fn(x, a = calc(x)) { // ... }
Prikaži ovu nit
Kraj razgovora
Novi razgovor -
-
-
Since you're here, we just released our React Hooks workshop online. Please check it out!
https://twitter.com/ReactTraining/status/1207716100017799168?s=19 …
Prikaži ovu nitHvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
-
-
Is this similar to Python where that default arg is only calculated once and then reused across calls? If it is, that’s bad news, my dude.
-
Nope. It's recalculated on every call.
Kraj razgovora
Novi razgovor -
-
-
Nothing wrong with using it. In fact Babel already handles this correctly. You can only reference parameters declared before the expression. Which Babel also correctly errors on.
-
(Nothing wrong with using it in reference to those in the replies saying it’s bad...)
- Još 1 odgovor
Novi razgovor -
-
-
Please never use this.
-
I ... I think I already did

- Još 3 druga odgovora
Novi razgovor -
-
-
Is it just babel or natively?
-
It's native JS
Kraj razgovora
Novi razgovor -
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.

New React Hooks on-demand workshop!
Learn React Hooks by building key features of a realistic app. After teaching this content to thousands, we've packaged it up into and on-demand course just for you.
25% off through December 31st