Why js for loops can traverse strings

I don"t see the source of the for traversal string, but I use it all the time. Want to know why

clipboard.png

Sep.03,2021

set a string variable in the console, and you can find that the iterator is implemented by looking at the prototype chain of the variable by _ _ proto__ . For more information about iterators, please refer to here

.


any iterator can be implemented


because js is a weak language

Menu