Re: [IndexedDB] Attributes with undefined vs. null

On Wed, Nov 7, 2012 at 10:53 AM, Joshua Bell <jsbell@chromium.org> wrote:
> Various atttributes in IndexedDB signal "no value" with |undefined|:
>
> IDBKeyRange.lowerBound (if not set)
> IDBKeyRange.upperBound (if not set)
> IDBRequest.result (on error, or on successful deleteDatabase/get with no
> value/delete/clear)
> IDBCursor.key (if no found record)
> IDBCursor.primaryKey (if no found record)
> IDBCursorWithValue.value (if no found record)
>
> It's been pointed out that most Web platform specs use |null| rather than
> |undefined| for signaling these states. I seem to recall a push in the
> direction of using |undefined| rather than |null| in the IndexedDB spec bit
> over a year ago, but my bugzilla-fu was weak. Can anyone discuss or justify
> this deviation from the norm?
>
> (I feel like there's been a trend over the past few years in embrace
> ECMAScript's |undefined| value rather than trying to pretend it doesn't
> exist, but that may be my imagination. IDB's use of |undefined| didn't
> strike me as unusual until it was pointed out.)

I think ECMAScript generally tries to think of 'undefined' as 'no
value' whereas 'null' means 'no object'.

So I think in the above cases 'undefined' seems like a better fit.

I don't feel strongly though.

/ Jonas

Received on Saturday, 16 March 2013 11:36:16 UTC