<?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"
	>
<channel>
	<title>Comments on: Tips for Programming JavaScript Functions</title>
	<atom:link href="http://www.zachleat.com/web/2008/03/28/tips-for-programming-javascript-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zachleat.com/web/2008/03/28/tips-for-programming-javascript-functions/</link>
	<description></description>
	<pubDate>Thu, 21 Aug 2008 10:19:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: Zach Leatherman</title>
		<link>http://www.zachleat.com/web/2008/03/28/tips-for-programming-javascript-functions/#comment-682</link>
		<dc:creator>Zach Leatherman</dc:creator>
		<pubDate>Wed, 16 Apr 2008 23:39:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.zachleat.com/web/2008/03/28/tips-for-programming-javascript-functions/#comment-682</guid>
		<description>You're right, I didn't word that correctly.

I think it should say:
"It's easier to use arg1 such that if you pass in a value, it should be true, or at least evaluate to true.  Passing in false or null should be treated identically for coding that's easier on the brain."

Point well taken though.</description>
		<content:encoded><![CDATA[<p>You&#8217;re right, I didn&#8217;t word that correctly.</p>
<p>I think it should say:<br />
&#8220;It&#8217;s easier to use arg1 such that if you pass in a value, it should be true, or at least evaluate to true.  Passing in false or null should be treated identically for coding that&#8217;s easier on the brain.&#8221;</p>
<p>Point well taken though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexei M</title>
		<link>http://www.zachleat.com/web/2008/03/28/tips-for-programming-javascript-functions/#comment-679</link>
		<dc:creator>Alexei M</dc:creator>
		<pubDate>Wed, 16 Apr 2008 15:08:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.zachleat.com/web/2008/03/28/tips-for-programming-javascript-functions/#comment-679</guid>
		<description>"Don't ever use arg1 in a way that would have you passing in false, because false and null are the same in a boolean comparison."

Dude, there are lots of times when an empty string is a perfectly acceptable value and does not designate the absence of the parameter. If you check against undefined you don't have to worry about this.

I ran into a very similar issue recently where I was checking for browser functionality like this:

var text = (el.textContent ? el.textContent : el.innerText);

The fix, depending on your tolerance for obfuscation, is either

var text = (el.textContent !== undefined ? el.textContent : el.innerText);

or

var text = el.textContent &#124;&#124; el.innerText &#124;&#124; ''.</description>
		<content:encoded><![CDATA[<p>&#8220;Don&#8217;t ever use arg1 in a way that would have you passing in false, because false and null are the same in a boolean comparison.&#8221;</p>
<p>Dude, there are lots of times when an empty string is a perfectly acceptable value and does not designate the absence of the parameter. If you check against undefined you don&#8217;t have to worry about this.</p>
<p>I ran into a very similar issue recently where I was checking for browser functionality like this:</p>
<p>var text = (el.textContent ? el.textContent : el.innerText);</p>
<p>The fix, depending on your tolerance for obfuscation, is either</p>
<p>var text = (el.textContent !== undefined ? el.textContent : el.innerText);</p>
<p>or</p>
<p>var text = el.textContent || el.innerText || &#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zach Leatherman</title>
		<link>http://www.zachleat.com/web/2008/03/28/tips-for-programming-javascript-functions/#comment-611</link>
		<dc:creator>Zach Leatherman</dc:creator>
		<pubDate>Sat, 29 Mar 2008 14:50:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.zachleat.com/web/2008/03/28/tips-for-programming-javascript-functions/#comment-611</guid>
		<description>Absolutely, that's a good one too.  For the non-computer scientists out there, that's a method called &lt;a href="http://en.wikipedia.org/wiki/Short-circuit_evaluation" rel="nofollow"&gt;short circuit evaluation&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Absolutely, that&#8217;s a good one too.  For the non-computer scientists out there, that&#8217;s a method called <a href="http://en.wikipedia.org/wiki/Short-circuit_evaluation" rel="nofollow">short circuit evaluation</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kangax</title>
		<link>http://www.zachleat.com/web/2008/03/28/tips-for-programming-javascript-functions/#comment-610</link>
		<dc:creator>kangax</dc:creator>
		<pubDate>Sat, 29 Mar 2008 06:23:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.zachleat.com/web/2008/03/28/tips-for-programming-javascript-functions/#comment-610</guid>
		<description>I find myself using alternative syntax quite often:

runDoSomething &#38;&#38; doSomething();</description>
		<content:encoded><![CDATA[<p>I find myself using alternative syntax quite often:</p>
<p>runDoSomething &amp;&amp; doSomething();</p>
]]></content:encoded>
	</item>
</channel>
</rss>
