<?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/"
	>
<channel>
	<title>Comments on: Numbers And Number Format Function</title>
	<atom:link href="http://mattsnider.com/languages/javascript/numbers-and-number-format-function/feed/" rel="self" type="application/rss+xml" />
	<link>http://mattsnider.com/languages/javascript/numbers-and-number-format-function/</link>
	<description>Understanding JavaScript and Frameworks</description>
	<pubDate>Tue, 06 Jan 2009 13:36:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: JavaScript Number Format Function by Matt Snider &#124; Just Talk About Web</title>
		<link>http://mattsnider.com/languages/javascript/numbers-and-number-format-function/comment-page-1/#comment-29760</link>
		<dc:creator>JavaScript Number Format Function by Matt Snider &#124; Just Talk About Web</dc:creator>
		<pubDate>Tue, 16 Dec 2008 07:36:03 +0000</pubDate>
		<guid isPermaLink="false">http://mattsnider.com/javascript/numbers-and-number-format-function/#comment-29760</guid>
		<description>[...] programming language&#8221;, Matt tried to explain how number is treated in JS (read more here). Here are build-in functions of Number object supported by different IE and Firefox [...]</description>
		<content:encoded><![CDATA[<p>[...] programming language&#8221;, Matt tried to explain how number is treated in JS (read more here). Here are build-in functions of Number object supported by different IE and Firefox [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clariman</title>
		<link>http://mattsnider.com/languages/javascript/numbers-and-number-format-function/comment-page-1/#comment-8621</link>
		<dc:creator>Clariman</dc:creator>
		<pubDate>Sun, 30 Mar 2008 10:10:14 +0000</pubDate>
		<guid isPermaLink="false">http://mattsnider.com/javascript/numbers-and-number-format-function/#comment-8621</guid>
		<description>Hi Matt. Your number formatting function looks to be just what I need. I am fairly new to Javascript but have written a fairly complex (to me) online calculator and I would like to use your function to properly format the output using the 0,000.00 format. Could you clarify how I pass parameters to the routine and how I define the routine within my HTML page. As I said, I am fairly new to Javascript so apologies for asking a rather basic question. If you want to see the actual calculator, it is "SOA Calc" under the calculator menu from the homepage.
Thanks
Clariman</description>
		<content:encoded><![CDATA[<p>Hi Matt. Your number formatting function looks to be just what I need. I am fairly new to Javascript but have written a fairly complex (to me) online calculator and I would like to use your function to properly format the output using the 0,000.00 format. Could you clarify how I pass parameters to the routine and how I define the routine within my HTML page. As I said, I am fairly new to Javascript so apologies for asking a rather basic question. If you want to see the actual calculator, it is &#8220;SOA Calc&#8221; under the calculator menu from the homepage.<br />
Thanks<br />
Clariman</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Snider</title>
		<link>http://mattsnider.com/languages/javascript/numbers-and-number-format-function/comment-page-1/#comment-6553</link>
		<dc:creator>Matt Snider</dc:creator>
		<pubDate>Tue, 04 Mar 2008 16:21:18 +0000</pubDate>
		<guid isPermaLink="false">http://mattsnider.com/javascript/numbers-and-number-format-function/#comment-6553</guid>
		<description>Thanks Gary, I forget to escape my backslashes. It is fixed now.</description>
		<content:encoded><![CDATA[<p>Thanks Gary, I forget to escape my backslashes. It is fixed now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary</title>
		<link>http://mattsnider.com/languages/javascript/numbers-and-number-format-function/comment-page-1/#comment-6537</link>
		<dc:creator>Gary</dc:creator>
		<pubDate>Tue, 04 Mar 2008 12:40:24 +0000</pubDate>
		<guid isPermaLink="false">http://mattsnider.com/javascript/numbers-and-number-format-function/#comment-6537</guid>
		<description>The final replace regexp is wrong

return format.replace(/[d,?.?]+/, fnum);</description>
		<content:encoded><![CDATA[<p>The final replace regexp is wrong</p>
<p>return format.replace(/[d,?.?]+/, fnum);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Snider</title>
		<link>http://mattsnider.com/languages/javascript/numbers-and-number-format-function/comment-page-1/#comment-6151</link>
		<dc:creator>Matt Snider</dc:creator>
		<pubDate>Fri, 29 Feb 2008 01:29:39 +0000</pubDate>
		<guid isPermaLink="false">http://mattsnider.com/javascript/numbers-and-number-format-function/#comment-6151</guid>
		<description>Mills, You are right about equality being difficult with Number Objects. However, a simple equality function  like

.equals(o) {
return this.valueOf() === o.valueOf();
}

usually does the trick. However, it also turns out that JavaScript does apply all methods attached to the Number.prototype to any Number variable automatically. So you can do:

var i = 1;
i.format('$0,0');

but you can't do

1.toFixed('$0,0');

As such, there is little reason to force cast to the Number Object.</description>
		<content:encoded><![CDATA[<p>Mills, You are right about equality being difficult with Number Objects. However, a simple equality function  like</p>
<p>.equals(o) {<br />
return this.valueOf() === o.valueOf();<br />
}</p>
<p>usually does the trick. However, it also turns out that JavaScript does apply all methods attached to the Number.prototype to any Number variable automatically. So you can do:</p>
<p>var i = 1;<br />
i.format(&#8217;$0,0&#8242;);</p>
<p>but you can&#8217;t do</p>
<p>1.toFixed(&#8217;$0,0&#8242;);</p>
<p>As such, there is little reason to force cast to the Number Object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MillsJROSS</title>
		<link>http://mattsnider.com/languages/javascript/numbers-and-number-format-function/comment-page-1/#comment-5984</link>
		<dc:creator>MillsJROSS</dc:creator>
		<pubDate>Tue, 26 Feb 2008 15:24:53 +0000</pubDate>
		<guid isPermaLink="false">http://mattsnider.com/javascript/numbers-and-number-format-function/#comment-5984</guid>
		<description>While you are correct on the truthiness aspect, I think it's misleading to say "The second distinction is that a Number object has several functions available on its prototype." These functions are also available to the Number literal. 

While the truthiness aspect is true...with numbers I'd argue it's more correct to code with equality operators, that are explicit in their meaning. "if(numLiteral === 0)" checks specifically whether or not the numLiteral is 0. However, the same statement with numObject, would be false, as the === operator doesn't do the conversion from a number object to a number literal. The == operator will be true (assuming both numbers are equal to zero).

I generally avoid using Number Objects, mostly out of personal preference. However, one potential advantage they do have, is you can add attributes to Number Objects, but not Number literals. So numberObject.x = 2 would be okay...numberLiteral.x = 2, probably won't get a syntax error, but numberLiteral.x will still be undefined. I haven't ever had to add an attribute to a number object, but that doesn't mean it couldn't be useful.

I'm not a fan of extending native objects, but to each his own. Otherwise, good read.</description>
		<content:encoded><![CDATA[<p>While you are correct on the truthiness aspect, I think it&#8217;s misleading to say &#8220;The second distinction is that a Number object has several functions available on its prototype.&#8221; These functions are also available to the Number literal. </p>
<p>While the truthiness aspect is true&#8230;with numbers I&#8217;d argue it&#8217;s more correct to code with equality operators, that are explicit in their meaning. &#8220;if(numLiteral === 0)&#8221; checks specifically whether or not the numLiteral is 0. However, the same statement with numObject, would be false, as the === operator doesn&#8217;t do the conversion from a number object to a number literal. The == operator will be true (assuming both numbers are equal to zero).</p>
<p>I generally avoid using Number Objects, mostly out of personal preference. However, one potential advantage they do have, is you can add attributes to Number Objects, but not Number literals. So numberObject.x = 2 would be okay&#8230;numberLiteral.x = 2, probably won&#8217;t get a syntax error, but numberLiteral.x will still be undefined. I haven&#8217;t ever had to add an attribute to a number object, but that doesn&#8217;t mean it couldn&#8217;t be useful.</p>
<p>I&#8217;m not a fan of extending native objects, but to each his own. Otherwise, good read.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
