use the most succing code then take a quick look at the profile against a large set of data.
I would say, always ... write the most READABLE code that you still feel is performant, then profile it. If it's fine from an overall performance standpoint, you are good.
That's it! It's not rocket science (well, it might be, but usually not if we're talking about things like JavaScript).
You don't even need to comment it! It just makes sense from looking at it and is fine. Who cares if it's 3 ms slower than the other version that is 10 lines longer? If that is not impacting your users, move on.
2
u/[deleted] Jun 10 '16
in client work, how often is forEach actually an issue? use the most succing code then take a quick look at the profile against a large set of data.
for less code, easier to read, and of course if isn't causing jank, it makes sense to go with forEach.