typeof null

Mikeal Rogers mikeal.rogers at gmail.com
Tue May 8 20:48:42 PDT 2012


+1 

this is something even seasoned js developers routinely trip over. 

-- 
Mikeal Rogers
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Tuesday, May 8, 2012 at 8:10 PM, Douglas Crockford wrote:

> On 5/8/2012 2:45 PM, David Herman wrote:
> > On May 8, 2012, at 9:19 AM, Rick Waldron wrote:
> > 
> > > non-strict, non-opt-in:
> > > 
> > > typeof null === "null"; // false
> > > 
> > > implied opt-in:
> > 
> > Changing typeof null always seemed questionable to me in terms of value.
> > It doesn't really give you significant new functionality, it just kinda
> > seems "more sensible". But adding it would just make things *more*
> > messy, for very little gain. Since we can't eliminate the old typeof
> > semantics, we end up with the language having different semantics in
> > different contexts.
> > 
> 
> 
> The issue isn't typeof null. null === is a more convenient test. The 
> issue is that typeof object gives a false positive when the value is 
> null. So sensing that a value is an object is error prone. We need a 
> simple, reliable test for objectness.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120508/8e3d588f/attachment.html>


More information about the es-discuss mailing list