- From: Garrett Smith <dhtmlkitchen@gmail.com>
- Date: Tue, 27 May 2008 16:29:10 -0700
- To: "Jonas Sicking" <jonas@sicking.cc>
- Cc: public-webapi@w3.org, "Maciej Stachowiak" <mjs@apple.com>, "Ian Hickson" <ian@hixie.ch>, "Anne van Kesteren" <annevk@opera.com>
On Tue, May 27, 2008 at 3:38 PM, Jonas Sicking <jonas@sicking.cc> wrote: > Hey Jonas, > Granted, this is partially due to a javascript spec "bug", null really > should have serialized to "" rather than "null". > The value null, when passed to ToString, converts to the string literal "null". I don't agree that that's a bug. This is how the language was designed and I think it was a right choice. Other programming languages use this approach, too. I think it is intuitive because: var el = document.getElementById( arg ); console.log( el ); - will print "null" to the console, if arg is not found (resulting in el being null). This is useful. It is very simple, when desired, to do:- if(s === null) s = ""; It would seem wrong for null to convert to the string "" when passed to ToString. I don't suppose you'd rather have ToString( Undefined ) to result in "undefined"? Garrett
Received on Tuesday, 27 May 2008 23:29:53 UTC