Why does Array.from accept non-iterable arraylikes?
domenic at domenicdenicola.com
Wed Jun 26 08:16:39 PDT 2013
From: Claude Pache
> implement/polyfill the iteration protocol in both old and new environments, using `GetIteratorSymbol()` where @@iterator is needed. If that `GetIteratorSymbol()` function is readily available in a standard place, it will allow different libraries to cooperate.
I think this is not necessary for library cooperation or forward-compatible polyfilling. It may make it *nicer*, but it's not necessary, and I'd predict not even that helpful.
It's very easy for a community to standardize on a simple property name, whether it be `iterator` or `__iterator__`, without needing a blessed one handed down from TC39. The polyfill community can probably figure this out themselves. I can't see any polyfill maintainers rejecting a pull request to switch to a more widely-used name. And I don't think there will be that many incompatible polyfill libraries out there anyway; in ES5 at least, we've seen one ascendant.
As for forward compatibility, this is pretty simple: just use `eval`. Icky and annoying, but [it works]. If you detect native iterator support, don't polyfill.
More information about the es-discuss