-
Notifications
You must be signed in to change notification settings - Fork 90
Description
Is it necessary to cache object properties and iteration results? I believe this will be pretty difficult to optimize out in engines and transpilers without sacrificing correctness, so it may be a real performance cost at runtime. The "access multiple times" semantics seem pretty intuitive/direct to me.
I understand that there is some concern about exhausting iterators. However, array destructuring is for iterables--you always get a fresh call to [Symbol.iterator] before something else happens, and you could do your caching in there when it's important to you. I'm not sure if we should be defending against usage patterns where iteration is destructive.
(I thought I had an issue thread about this, where I was worrying about soundness/consistency, but the current Map approach is consistent; anyway, I can't find that old thread, so filing a new one.)