On Wed, Sep 23, 2009 at 14:28, João Eiras <[email protected]> wrote: > On Wed, 23 Sep 2009 23:03:38 +0200, Erik Arvidsson > <[email protected]> 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. > > > -- erik
