Skip to main content
18 events
when toggle format what by license comment
Jun 18, 2020 at 15:00 history tweeted twitter.com/StackSoftEng/status/1273631584361611266
Jun 16, 2020 at 10:01 history edited CommunityBot
Commonmark migration
Jun 10, 2020 at 15:10 vote accept Kenneth Moore
May 21, 2020 at 17:58 answer added JimmyJames timeline score: 2
May 21, 2020 at 16:38 comment added JimmyJames In your question, you use the terminology 'for' and 'while' to distinguish between the two but whether you use a for loop or a while loop construction doesn't have any significant impact. If you replace sum += array.pop() with sum += array[i] you can see it's not about for versus while but about pop versus array indexing. I think you understand this but it might remove some confusion about what you are asking.
May 21, 2020 at 15:36 comment added JimmyJames Also related: stackoverflow.com/questions/8423493/…
May 21, 2020 at 15:18 comment added JimmyJames Sorry, I didn't mean to suggest that this is definitely the wrong place. Two of the close votes are suggesting that and I think it's a bit of a gray area. It's very interesting for sure.
May 20, 2020 at 21:57 comment added Robert Harvey Related: Why is array.push sometimes faster than array[n] = value?
May 20, 2020 at 21:32 history edited Kenneth Moore CC BY-SA 4.0
Updating Question to be more direct and updated a screen capture
May 20, 2020 at 20:23 comment added Kenneth Moore @JimmyJames, I always viewed StackOverflow as a place for questions about the "how" of development. I posted this here hoping to find someone who could help me understand why this method would "measure" so much faster. Is this related the bench-marking tools, or does the reduction in array size on each iteration actually add up that much?
May 20, 2020 at 20:13 comment added Kenneth Moore @RobertHarvey, the jsBench example sums up the array values while the jsperf examples are bunch of no-ops.
May 20, 2020 at 20:03 comment added Robert Harvey Do either of these benchmarks produce any valid output (i.e. an actual sum of some non-trivial array or stack)? Because the pop version just looks like a bunch of no-ops.
May 20, 2020 at 18:25 comment added JimmyJames I think the problem is that it's not clear this question belongs here. It might be a better fit for stackoverflow. If you refocused on why this is the case, it might be more appropriate here.
May 20, 2020 at 17:52 history edited Kenneth Moore CC BY-SA 4.0
I am adding images to provide context for the links. I removed unnecessary details and refined the content to focus on the questions I am seeking answers for.
May 20, 2020 at 17:38 history edited Kenneth Moore CC BY-SA 4.0
Adding images to provide context for the links. Removing unnecessary details and refined the content to focus on the questions I am seeking answers for.
May 20, 2020 at 17:30 review Close votes
Jun 7, 2020 at 3:03
May 20, 2020 at 17:08 review First posts
Jun 1, 2020 at 19:37
May 20, 2020 at 17:02 history asked Kenneth Moore CC BY-SA 4.0