[whatwg] Web Storage: structured clones lead to ambiguity in detecting if a key is set w/ getItem()

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
> issue.

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.



Received on Wednesday, 23 September 2009 14:37:41 UTC