Optionally ignoring case in String.prototype.contains()?

Tab Atkins Jr. jackalmage at gmail.com
Wed Aug 28 10:48:38 PDT 2013


On Wed, Aug 28, 2013 at 10:45 AM, Norbert Lindenberg
<ecmascript at lindenbergsoftware.com> wrote:
> $ 'Hallo Friedrichstraße'.contains('STRASSE', { ignoreCase: true })
> true? false?
>
> $ 'hello İzmir'.contains('İZMİR', { ignoreCase: true })
> true? false?
>
> In other words, should ignoreCase be based on Unicode upper case conversion, lower case conversion, or case folding, with or without locale dependent rules? I suspect any choice would surprise some people.

It should be based on exactly the same thing as the regex flag.  That
is, these two lines should return identical results in all cases:

    'Hallo Friedrichstraße'.contains('STRASSE', { ignoreCase: true })
    'Hallo Friedrichstraße'.search(/STRASSE/i) != -1

Anything else would be surprising on a language level.

~TJ


More information about the es-discuss mailing list