Re: APIs that overload numbers and strings

On Sat, Apr 13, 2013 at 10:36 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> 3)  The third one is IndexedDB, which allows primitive numbers and primitive
> strings (but not Number or String objects, note) as key values.  It also
> allows Arrays and Dates, but those are a separate concern.  IndexedDB treats
> 42 and "42" as different keys.  Right now it does this via using "any" in
> IDL and then defining the whole thing in terms of introspection of the
> original ES value involved.  This API seems pretty weird to me, at first
> glance, but there is quite a bit of existing library API precedent for
> treating String objects and primitive strings differently, as far as I can
> tell...  Checking for typeof == "string" is pretty common.

Note that if we in indexedDB treated all numbers as strings, that
would mean that 8 would sort between 70 and 90.

/ Jonas

Received on Sunday, 14 April 2013 22:51:33 UTC