tc39/js-outreach-groups

[Review] How does in-built Array iterator work?

bendtherules opened this issue · 4 comments

I wrote a blog post on how in-built Array iterator works - https://blog.bendtherul.es/how-does-in-built-array-iterator-work-ckciw2lr900d0xas144h5fpwm

Would like to get some feedback.

(Word count - 626 including the refresher section on iterator protocol. Without that, 527)

@laurieontech Can you please review this when free?

What was the feedback on this one? Should i reduce the length, or this is good to go?

tdd commented

Hey @bendtherules,

Cool article! I'm not sure whether this group is looking for dive-into-implementation articles so much as API-surface articles, but I'm a sucker for knowing the internals of things, so I like it 👍

Just a few things off the top of my head:

  • I might be wrong, but I think "built-in" is the correct form of "in-built"?
  • First par: might want to add Array.from(someArray) as an example of cloning someArray, in addition to spread and .values().
  • First par: I was initially confused by your "to get multiple values". After all, slice gets multiple values out of an array. Perhaps you meant "to clone all the values from" or "to get a fresh copy of all the values from" or "to get a copy of"?
  • “this method next() returns a response inwith this structure…"
  • The Implications part is, IMHO, the most value-added part of the article.

Best,

Thanks for your detailed feedback @tdd.

About your observations -
1 - Yes, i checked and looks like built-in is the nore common form. I can edit that.
2 and 3 - I used the rest operator and .values example because both of them use the iterator internally, while others like slice (probably) don't. I guess it would be better to say copy/clone all variables, like you suggested.

4 - I will fix that.

5 - True, implications is the more juicy part. My hope is that after seeing some edge cases there, readers will look back at the full algo to understand them.

(Also yes, most of the articles here are around new proposals, but IMO, it's also interesting to look back at the "old" stuff to really understand how it works.)

Thanks again for taking a detailed look.