4 ms·
Has anyone read the semantics of the linked partial application proposal [0]? > Note that this also means that more involved references are captured in their e
by seniorsassycat 9y ago
Has anyone read the semantics of the linked partial application proposal [0]?
> Note that this also means that more involved references are captured in their entirety and should be stored in a local variable if they may have unintended side-effects should the partially applied function result be called more than once
const a = [{ c: x => x + 1 }, { c: x => x + 2 }];
let b = 0;
const g = a[b++].c(?);
b; // 0
g(1); // 2
g(1); // 3
b; // 2
`a[b++].c` is not evaluated until the partially applied function `g` is called. Event `a[b++]` and `b++` are not evaluated.
It is unclear to me when `const g = Math.random().toFixed(?)` would evaluate `Math.random()`.
[0]: https://github.com/rbuckton/proposal-partial-application#semantics https://github.com/rbuckton/proposal-partial-application#sem...