On Wed, May 25, 2011 at 10:52 PM, Aaron Jacobs <jacobsa@google.com> wrote:
Hmm, but does it make sense to say a default constructed value is all
of null, an array, and an object? Wouldn't it make more sense to have

In JS, default-constructed values are 'undefined', not null:

[stephan@cheyenne:~/tmp]$ js 
Rhino 1.7 release 2 2010 11 17
js> var x; print(typeof x);
undefined

(And (typeof null) == object, for some brain-dead reason or other.)

IMO that is the proper default-construction semantics. The further a JSON impl deviates from basic JS behaviours, the less portable it is likely to become.


isArray (and only isArray) start returning true once the value is
"turned into" an array by appending something to it?

Using JS as a baseline:

js> x[1] = 3;
js: "<stdin>", line 3: uncaught JavaScript runtime exception: TypeError: Cannot set property "1.0" of undefined to "3"
at <stdin>:3

that's the behaviour most would expect, i think (as opposed to automatic promotion to an Array or Object).

--
----- stephan beal
http://wanderinghorse.net/home/stephan/