[whatwg] Web Storage: structured clones lead to ambiguity in detecting if a key is set w/ getItem()
erik.arvidsson at gmail.com
Wed Sep 23 14:37:41 PDT 2009
On Wed, Sep 23, 2009 at 14:28, João Eiras <joaoe at opera.com> wrote:
> On Wed, 23 Sep 2009 23:03:38 +0200, Erik Arvidsson
> <erik.arvidsson at gmail.com> wrote:
>> What are the arguments against adding a containsKey method? This would
>> map consistently to the in operator and hasOwnProperty in ES5.
>> object.containsKey(name) would be mapped to [[GetOwnProperty]](object,
>> name) !== undefined in ES5 meta language. That seems most consistent
>> to existing APIs.
> A containsKey or hasItem, preferably, would still not address the ambiguity
ES and most other languages that do not throw when you try to get a
non existing item out of a collection will have this problem. If they
return a value, getItem will never be able to tell if that value was
due to an absent item or not. The only way to make getItem handle this
is to either throw or return two values. Both are not very consistent
with other web apis.
More information about the whatwg