<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
	>
<channel>
	<title>Comments on: JavaScript values null and undefined</title>
	<atom:link href="http://pierrespring.com/2010/04/25/javascript-null-undefine/feed/" rel="self" type="application/rss+xml" />
	<link>http://pierrespring.com/2010/04/25/javascript-null-undefine/</link>
	<description>geek, punk, pussy …</description>
	<lastBuildDate>Sun, 05 May 2013 13:21:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: Nick Weidmann</title>
		<link>http://pierrespring.com/2010/04/25/javascript-null-undefine/comment-page-1/#comment-3078</link>
		<dc:creator>Nick Weidmann</dc:creator>
		<pubDate>Tue, 26 Apr 2011 13:49:55 +0000</pubDate>
		<guid isPermaLink="false">http://pierrespring.com/?p=13#comment-3078</guid>
		<description>This really answered my problem, warm regards!</description>
		<content:encoded><![CDATA[<p>This really answered my problem, warm regards!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yoan</title>
		<link>http://pierrespring.com/2010/04/25/javascript-null-undefine/comment-page-1/#comment-9</link>
		<dc:creator>Yoan</dc:creator>
		<pubDate>Mon, 03 May 2010 16:37:21 +0000</pubDate>
		<guid isPermaLink="false">http://pierrespring.com/?p=13#comment-9</guid>
		<description>Applying `delete` on an array seems very counter-intuitive to me. I&#039;d expect it to behave like (the awesome) splice but it doesn&#039;t.
[cc lang=&quot;javascript&quot;]
js&gt; var a = [1,2,3]
js&gt; delete a[1]
true
js&gt; a.hasOwnProperty(2)
false
js&gt; a.length
3
[/cc]
it&#039;s not the same as doing it manually though (even if you say that it makes no sense)
[cc lang=&quot;javascript&quot;]
js&gt; a[2] = undefined
js&gt; a.hasOwnProperty(2)
true
js&gt; for(var i in a){ print(i) }
0
2
[/cc]

It&#039;s very very confusing, I think. I&#039;m feeling all PHPish at this point :-)

@michael, @shvi just go with the ternary operator: [cci lang=&quot;javascript&quot;]return typeof this.name === &quot;object&quot; ? this.name : &quot;No named yet&quot;[/cci]</description>
		<content:encoded><![CDATA[<p>Applying `delete` on an array seems very counter-intuitive to me. I&#8217;d expect it to behave like (the awesome) splice but it doesn&#8217;t.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">js<span style="color: #339933;">&gt;</span> <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span><br />
js<span style="color: #339933;">&gt;</span> <span style="color: #000066; font-weight: bold;">delete</span> a<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><br />
<span style="color: #003366; font-weight: bold;">true</span><br />
js<span style="color: #339933;">&gt;</span> a.<span style="color: #660066;">hasOwnProperty</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #003366; font-weight: bold;">false</span><br />
js<span style="color: #339933;">&gt;</span> a.<span style="color: #660066;">length</span><br />
<span style="color: #CC0000;">3</span></div></div>
<p>it&#8217;s not the same as doing it manually though (even if you say that it makes no sense)</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">js<span style="color: #339933;">&gt;</span> a<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> undefined<br />
js<span style="color: #339933;">&gt;</span> a.<span style="color: #660066;">hasOwnProperty</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #003366; font-weight: bold;">true</span><br />
js<span style="color: #339933;">&gt;</span> <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #000066; font-weight: bold;">in</span> a<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><br />
<span style="color: #CC0000;">0</span><br />
<span style="color: #CC0000;">2</span></div></div>
<p>It&#8217;s very very confusing, I think. I&#8217;m feeling all PHPish at this point :-)</p>
<p>@michael, @shvi just go with the ternary operator: <code class="codecolorer javascript default"><span class="javascript"><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">typeof</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #000066;">name</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">&quot;object&quot;</span> <span style="color: #339933;">?</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #000066;">name</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;No named yet&quot;</span></span></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris D</title>
		<link>http://pierrespring.com/2010/04/25/javascript-null-undefine/comment-page-1/#comment-8</link>
		<dc:creator>Chris D</dc:creator>
		<pubDate>Wed, 28 Apr 2010 20:04:58 +0000</pubDate>
		<guid isPermaLink="false">http://pierrespring.com/?p=13#comment-8</guid>
		<description>Smile... :-)
Way to go. Nice to see you working on this blog. Keep up the good work!</description>
		<content:encoded><![CDATA[<p>Smile&#8230; :-)<br />
Way to go. Nice to see you working on this blog. Keep up the good work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pierre Spring</title>
		<link>http://pierrespring.com/2010/04/25/javascript-null-undefine/comment-page-1/#comment-7</link>
		<dc:creator>Pierre Spring</dc:creator>
		<pubDate>Tue, 27 Apr 2010 11:28:22 +0000</pubDate>
		<guid isPermaLink="false">http://pierrespring.com/?p=13#comment-7</guid>
		<description>@yoan: I had never heared of the [cci]in[/cci] operator before. Yet, for the purpse of this article, which is to understand the difference between [cci]null[/cci] and [cci]undefined[/cci] I think the examples are better off without it.

I read the link about deleting array elements. And my head kind of doesn&#039;t get why someone would do the following:
[cc lang=&quot;javascript&quot;]
var children = [&#039;Lou&#039;, &#039;Frank&#039;, Lillith];
children[2] = undefined; // makes no sense

children = [&#039;Lou&#039;, &#039;Frank&#039;, Lillith];
// is slow, yet the only solution not to
// fuck with the length property and having
// vanilla for loops working as expected. no?
children.splice(2,1);
[/cc]

@michael: Thanks for pointing out the shortcut. I&#039;ll edit the post right away! Now, what I meant to say about PHP is that I dislike the fact that it sets an undefined variable to [cci]null[/cci]. Not the fact that it triggers a notice. I like the fact that PHP triggers a notice, yet most people working with PHP do not display them ;)</description>
		<content:encoded><![CDATA[<p>@yoan: I had never heared of the <code class="codecolorer text default"><span class="text">in</span></code> operator before. Yet, for the purpse of this article, which is to understand the difference between <code class="codecolorer text default"><span class="text">null</span></code> and <code class="codecolorer text default"><span class="text">undefined</span></code> I think the examples are better off without it.</p>
<p>I read the link about deleting array elements. And my head kind of doesn&#8217;t get why someone would do the following:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> children <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Lou'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Frank'</span><span style="color: #339933;">,</span> Lillith<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
children<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> undefined<span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// makes no sense</span><br />
<br />
children <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Lou'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Frank'</span><span style="color: #339933;">,</span> Lillith<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">// is slow, yet the only solution not to</span><br />
<span style="color: #006600; font-style: italic;">// fuck with the length property and having</span><br />
<span style="color: #006600; font-style: italic;">// vanilla for loops working as expected. no?</span><br />
children.<span style="color: #660066;">splice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>@michael: Thanks for pointing out the shortcut. I&#8217;ll edit the post right away! Now, what I meant to say about PHP is that I dislike the fact that it sets an undefined variable to <code class="codecolorer text default"><span class="text">null</span></code>. Not the fact that it triggers a notice. I like the fact that PHP triggers a notice, yet most people working with PHP do not display them ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://pierrespring.com/2010/04/25/javascript-null-undefine/comment-page-1/#comment-6</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Mon, 26 Apr 2010 20:17:45 +0000</pubDate>
		<guid isPermaLink="false">http://pierrespring.com/?p=13#comment-6</guid>
		<description>I don&#039;t know if I follow your conclusion. In my opinion accessing a non existing property should very much throw an error, to prevent long debugging sessions when there&#039;s some evil typo in your code. At least that happens to me far more often than that I have a need for the behavior you described.

By the way, to make the second example (with null) less verbose, you can also use the fact that null evaluates to false and use this shortcut:
[cc lang=&quot;javascript&quot;]
return this.name &#124;&#124; &#039;Not named yet&#039;;
[/cc]</description>
		<content:encoded><![CDATA[<p>I don&#8217;t know if I follow your conclusion. In my opinion accessing a non existing property should very much throw an error, to prevent long debugging sessions when there&#8217;s some evil typo in your code. At least that happens to me far more often than that I have a need for the behavior you described.</p>
<p>By the way, to make the second example (with null) less verbose, you can also use the fact that null evaluates to false and use this shortcut:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #000066;">name</span> <span style="color: #339933;">||</span> <span style="color: #3366CC;">'Not named yet'</span><span style="color: #339933;">;</span></div></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yoan</title>
		<link>http://pierrespring.com/2010/04/25/javascript-null-undefine/comment-page-1/#comment-5</link>
		<dc:creator>Yoan</dc:creator>
		<pubDate>Mon, 26 Apr 2010 20:06:40 +0000</pubDate>
		<guid isPermaLink="false">http://pierrespring.com/?p=13#comment-5</guid>
		<description>I usually find the &quot;in&quot; operator way nicer to tests the presence of something, or the hasOwnProperty if you&#039;re picky. Once again, you must know what you&#039;re doing at any time: https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/in_Operator#Using_in_with_deleted_or_undefined_properties

Food for thought regarding the last example above: https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/delete_Operator#Deleting_array_elements</description>
		<content:encoded><![CDATA[<p>I usually find the &#8220;in&#8221; operator way nicer to tests the presence of something, or the hasOwnProperty if you&#8217;re picky. Once again, you must know what you&#8217;re doing at any time: <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/in_Operator#Using_in_with_deleted_or_undefined_properties" rel="nofollow">https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/in_Operator#Using_in_with_deleted_or_undefined_properties</a></p>
<p>Food for thought regarding the last example above: <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/delete_Operator#Deleting_array_elements" rel="nofollow">https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/delete_Operator#Deleting_array_elements</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
