Message from JavaScript discussions
November 2017
— But duck-typing is really the best possible way
Then, you can just use Symbol.iterator
which should behave the same always, it is a great abstraction for data structures
— If it has .map, it must work similar to an array-like structure
— Fair assumption
— I agree
— Plenty of libraries implement map, but not Symbol.iterator
— Since it's so new
— I do systems architecture, I write for programmers
— Maybe look into how to specify an iterable through the fantasy-land spec, and mimic those kinds of checks as well (if Symbol.iterator isn't present)
— So they are the user in this case
— It's very cool because you can easily make a lot polymorphic with less code... template engine can process an Array of Nodes or a NodeList equally with the same loop, and no glue
— Whereas, ofc, a NodeList doesn't have the brackets accessor, while an Array does... making them quite different when you try to write glue