https://plainenglish.io/blog/are-for-loops-better-than-arrays-filter-or-foreach-methods
Your overall application may become faster by a really tiny fraction (definitely not noticeable to the end-user) when using for loops, but the trade-off is readability and maintainability of the code, at least in my opinion (it’s also mentioned on the blog). Anyway, as others have said, it doesn’t really matter in real world, so use whichever one you’re more comfortable with.
Would while, do_while loops stand a chance Someone also did a comparison for switch, if and object access In the end am sure you would only be confined to a minute feature set of javascript or any language for that matter
i don't care about performance since it's very very very very very small on small project with less than 100 data i want to handle.
A bundler would be well suited for this kind of optimisation, give some rope to those that would be maintaining the code
For small data sets, you can actually cache on client side and do most of the calculations there. Appollo graphql already does this under the hood
There are sensible optimisations that humans can do that are hard for tools to do (today). Like using for loops over functions.
How about code you cannot directly influence like libraries?
I don't use many libs; I pick good ones if I can
They would stand a chance, yes
They are both slower than for loops
They should be the same speed
If 'if' is faster than 'switch' am sure they are different, could write the benchmarking code but currently constrained of time
I was talking about whiles only lol
Обсуждают сегодня