3 ms·
It's not worthless when you are writing an app that happens to run in the browser. I agree 1000-fold that the Array manipulation techniques are extremely easy
by goldenkey 13y ago
It's not worthless when you are writing an app that happens to run in the browser.
I agree 1000-fold that the Array manipulation techniques are extremely easy to read. Keep in mind though, you are creating a new copy of the [1-n]array through the slicing, and the overhead of the function call with forEach will matter on large Arrays. Really depends what you are building. Don't call performance optimization worthless.
- inglor 13y ago"Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%." - Knuth Micro benchmarks are not how we optimize - we profile.
- Eiwatah4 13y agoWho says the function call actually happens? If the function is short enough, they are a very good candidates for the JIT to inline. If they aren't short, the overhead of calling the function shouldn't matter much anymore.