instanceof Operator

Lars T Hansen lth at acm.org
Mon Oct 22 06:05:06 PDT 2007


On 10/22/07, P T Withington <ptw at pobox.com> wrote:
> IWBNI there were a single test for string-ness.  In ES3, you have to
> say:
>
>    typeof x == 'string' || (typeof x == 'object && x instanceof String)
>
> Am I right in thinking that in ES4 you will be able to say:
>
>    x is string
>
> to ask the same question?

You ask

  x is AnyString

instead.  AnyString is a predefined union type containing String and
string.  (Ditto AnyBoolean, AnyNumber.)

--lars



More information about the Es4-discuss mailing list