Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Strings **should** be considered as iterables #244

Closed

Description

With #233, strings are not considered as iterables. It's complete nonsense.

for (const c of 'abc') console.log(c); // => 'a', 'b', 'c'

[...'abc']; // => ['a', 'b', 'c']

'abc'[Symbol.iterator](); // => StringIterator

// etc., many other cases, but only here:

Iterator.from('abc'); // => TypeError

WTF? Yes, making strings iterable was a controversial decision - but since they are already iterable and it's not possible to change it - maybe it's better to stop break the language by adding inconsistencies?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions