Timeline for How to avoid global state without large function signatures?
Current License: CC BY-SA 3.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 4, 2020 at 16:20 | comment | added | Sonicsmooth | I don't know anything about javascript, but if it's anything like some other languages that support lambdas, then the inner functions are compiled as far as possible ahead of time, with the lexical context passed in at runtime. So you're not actually "creating" hundreds of inner functions at runtime, but rather just calling functions as with any other. | |
| Sep 24, 2014 at 11:41 | comment | added | CryptoCommander | I'll try to remember and let you know how it turns out! | |
| Sep 24, 2014 at 11:41 | comment | added | CryptoCommander | I can't up-vote this also, but this is a great answer. Just to provide me with some concrete numbers, I ended up writing 4 test files, one for each approach: Context arguments Functors Closures Prototypes and plan to run each of them a large number of times while a V8 profiler is watching them. I have a feeling that unless the functions are very large (which is bad design anyway!) or a large number of them are created (100s per call) that the performance difference will be minimal. I think that from a readability and code re-use perspective that the prototype or context method are best. | |
| Sep 24, 2014 at 11:34 | vote | accept | CryptoCommander | ||
| Sep 24, 2014 at 6:56 | history | answered | btilly | CC BY-SA 3.0 |