W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2012

RE: IndexedDB: undefined parameters

From: Aaron Powell <me@aaron-powell.com>
Date: Tue, 9 Oct 2012 22:28:56 +0000
To: Robert Ginda <rginda@chromium.org>, Boris Zbarsky <bzbarsky@mit.edu>
CC: Alec Flett <alecflett@chromium.org>, public-webapps <public-webapps@w3.org>
Message-ID: <6ED5F3CF043F35489214293D74026A24211E2CB2@EXMBX12.netplexity.local>
I believe it was part of the ES5 changes that brought this in, testing in both Chrome (23) and IE 10 with the following code snippet:

var bar = function () {
undefined = 42;

var foo;

console.assert(foo == undefined);
}

bar();

That will always return true, meaning that undefined wasn't modified. This means that it's safe to assume that undefined is undefined when passed into the IDB API (as all browsers supporting IDB already implement ES5).

Aaron Powell
MVP - Internet Explorer (Development) | FunnelWeb Team Member<http://funnelweblog.com/>

http://apowell.me<http://apowell.me/> | http://twitter.com/slace | Skype: aaron.l.powell | Github<http://github.com/aaronpowell/> | BitBucket<http://hg.apwll.me/>

From: rginda@google.com [mailto:rginda@google.com] On Behalf Of Robert Ginda
Sent: Wednesday, 10 October 2012 9:19 AM
To: Boris Zbarsky
Cc: Alec Flett; public-webapps
Subject: Re: IndexedDB: undefined parameters

On Tue, Oct 9, 2012 at 3:11 PM, Boris Zbarsky <bzbarsky@mit.edu<mailto:bzbarsky@mit.edu>> wrote:
On 10/9/12 6:04 PM, Robert Ginda wrote:
But I never, ever use the symbol-known-as
"undefined" in script, since it's actually a write-able variable.

For what it's worth, it's not anymore.  It used to be, but current ES makes it a readonly non-configurable property of the global.  Not sure to what extent UAs have caught up with the spec on that.

Oh, I wasn't aware of that.  I'd still avoid using undefined values to mean "I intentionally don't want to provide a value".  Null is more trustworthy for that, because it's not going to show up "on accident".  In my own private coding guidelines in my head, I only *test* for undefined.  It only appears as an rvalue in very rare cases, and when it does it appears as "(void 0)".

Of course in cases like this:

  function foo(undefined) {
    // Code using "undefined" here loses
  }

you still have a problem....

I'd suggest also treating null as missing if possible.

In general, or for the specific IDB case?

Well my own personal opinion would be in general, but I don't know what kind of repercussions that would have on other specifications and implementations.


Rob.



-Boris
Received on Wednesday, 10 October 2012 15:47:49 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:55 GMT