<?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>《给JavaScript新手的24条实用建议[TUTS+]》的评论</title> <atom:link href="http://blog.benhuoer.com/posts/24-javascript-best-practices-for-beginners.html/feed" rel="self" type="application/rss+xml" /><link>http://blog.benhuoer.com/posts/24-javascript-best-practices-for-beginners.html</link> <description>请用力生活</description> <lastBuildDate>Thu, 02 Feb 2012 06:18:43 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>作者：给JavaScript新手的24条实用建议_UEDspace</title><link>http://blog.benhuoer.com/posts/24-javascript-best-practices-for-beginners.html/comment-page-1#comment-1533</link> <dc:creator>给JavaScript新手的24条实用建议_UEDspace</dc:creator> <pubDate>Sun, 15 Nov 2009 16:51:44 +0000</pubDate> <guid
isPermaLink="false">http://blog.benhuoer.com/?p=1532#comment-1533</guid> <description>[...] 译文原文：给JavaScript新手的24条建议 [...]</description> <content:encoded><![CDATA[<p>[...] 译文原文：给JavaScript新手的24条建议 [...]</p> ]]></content:encoded> </item> <item><title>作者：给JavaScript新手的24条实用建议 &#171; ReeQi&#39;s Zone</title><link>http://blog.benhuoer.com/posts/24-javascript-best-practices-for-beginners.html/comment-page-1#comment-1196</link> <dc:creator>给JavaScript新手的24条实用建议 &#171; ReeQi&#39;s Zone</dc:creator> <pubDate>Mon, 06 Jul 2009 14:22:47 +0000</pubDate> <guid
isPermaLink="false">http://blog.benhuoer.com/?p=1532#comment-1196</guid> <description>[...] 英文原文：24-javascript-best-practices-for-beginners 译文原文：给JavaScript新手的24条建议  © [...]</description> <content:encoded><![CDATA[<p>[...] 英文原文：24-javascript-best-practices-for-beginners 译文原文：给JavaScript新手的24条建议  © [...]</p> ]]></content:encoded> </item> <item><title>作者：Bernhard Häussner</title><link>http://blog.benhuoer.com/posts/24-javascript-best-practices-for-beginners.html/comment-page-1#comment-1137</link> <dc:creator>Bernhard Häussner</dc:creator> <pubDate>Sat, 20 Jun 2009 14:13:52 +0000</pubDate> <guid
isPermaLink="false">http://blog.benhuoer.com/?p=1532#comment-1137</guid> <description>综合运用 #7 和 #14，还能这么写：
var container = document.getElementById(’container’);
var result = [];
for(var i = 0, len = someArray.length; i &lt; len; i++) {
result.push( ‘my number: ‘ + i);
console.log(i);
}
container.innerHtml = result.join();
(在Firefox 3里可能并不会有速度提升，因为他们已经优化了字串追加操作)
然后我觉得你可能需要把“var”放在len前面，不是么？（不知道在JS里面该如何做，但是在PHP这是必须的）</description> <content:encoded><![CDATA[<p>综合运用 #7 和 #14，还能这么写：</p><p>var container = document.getElementById(’container’);<br
/> var result = [];<br
/> for(var i = 0, len = someArray.length; i &lt; len; i++) {<br
/> result.push( ‘my number: ‘ + i);<br
/> console.log(i);<br
/> }<br
/> container.innerHtml = result.join();</p><p>(在Firefox 3里可能并不会有速度提升，因为他们已经优化了字串追加操作)</p><p>然后我觉得你可能需要把“var”放在len前面，不是么？（不知道在JS里面该如何做，但是在PHP这是必须的）</p> ]]></content:encoded> </item> <item><title>作者：Brenelz</title><link>http://blog.benhuoer.com/posts/24-javascript-best-practices-for-beginners.html/comment-page-1#comment-1136</link> <dc:creator>Brenelz</dc:creator> <pubDate>Sat, 20 Jun 2009 14:09:50 +0000</pubDate> <guid
isPermaLink="false">http://blog.benhuoer.com/?p=1532#comment-1136</guid> <description>关于第六条，我觉得可以把HTML赋值给某个变量来提升速度。然后在循环的外部指定innnerHTML，这么做把代码插入到DOM就只插了一次。
var container = document.getElementById(’container’);
var result = ”;
for(var i = 0, len = someArray.length; i &lt; len; i++) {
result += ‘my number: ‘ + i;
console.log(i);
}
container.innerHtml = result; </description> <content:encoded><![CDATA[<p>关于第六条，我觉得可以把HTML赋值给某个变量来提升速度。然后在循环的外部指定innnerHTML，这么做把代码插入到DOM就只插了一次。</p><p>var container = document.getElementById(’container’);<br
/> var result = ”;<br
/> for(var i = 0, len = someArray.length; i &lt; len; i++) {<br
/> result += ‘my number: ‘ + i;<br
/> console.log(i);<br
/> }<br
/> container.innerHtml = result;</p> ]]></content:encoded> </item> <item><title>作者：Joseph Pecoraro</title><link>http://blog.benhuoer.com/posts/24-javascript-best-practices-for-beginners.html/comment-page-1#comment-1135</link> <dc:creator>Joseph Pecoraro</dc:creator> <pubDate>Sat, 20 Jun 2009 14:01:18 +0000</pubDate> <guid
isPermaLink="false">http://blog.benhuoer.com/?p=1532#comment-1135</guid> <description>HTML4里type属性是必须的：
http://www.w3.org/TR/REC-html40/interact/scripts.html#edef-SCRIPT
HTML5里type属性默认值是“text/javascript”，可以省略：
http://dev.w3.org/html5/spec/Overview.html#script
As for removing the type attribute, I don’t actually see any mention of using the MIME type in the HTML4 spec. I may have missed it or it may just be a browser convention developed over the last 10 years. But for now, it might be better to just keep it in. How many servers do you know that are serving JS with the correct MIME type anyways? =)
说到去除type属性，我并没有在HTML4文档里发现任何关于设置MIME类型的规定。我可能错过了，或者它仅仅是过去十年中因为要方便浏览器开发而没有采用。话说回来，你又看到过多少正确设置了JS文件的MIME类型的服务器呢？</description> <content:encoded><![CDATA[<p>HTML4里type属性是必须的：<br
/> <a
href="http://www.w3.org/TR/REC-html40/interact/scripts.html#edef-SCRIPT" rel="nofollow">http://www.w3.org/TR/REC-html40/interact/scripts.html#edef-SCRIPT</a></p><p>HTML5里type属性默认值是“text/javascript”，可以省略：<br
/> <a
href="http://dev.w3.org/html5/spec/Overview.html#script" rel="nofollow">http://dev.w3.org/html5/spec/Overview.html#script</a></p><p>As for removing the type attribute, I don’t actually see any mention of using the MIME type in the HTML4 spec. I may have missed it or it may just be a browser convention developed over the last 10 years. But for now, it might be better to just keep it in. How many servers do you know that are serving JS with the correct MIME type anyways? =)<br
/> 说到去除type属性，我并没有在HTML4文档里发现任何关于设置MIME类型的规定。我可能错过了，或者它仅仅是过去十年中因为要方便浏览器开发而没有采用。话说回来，你又看到过多少正确设置了JS文件的MIME类型的服务器呢？</p> ]]></content:encoded> </item> <item><title>作者：Marc Grabanski</title><link>http://blog.benhuoer.com/posts/24-javascript-best-practices-for-beginners.html/comment-page-1#comment-1132</link> <dc:creator>Marc Grabanski</dc:creator> <pubDate>Sat, 20 Jun 2009 13:51:15 +0000</pubDate> <guid
isPermaLink="false">http://blog.benhuoer.com/?p=1532#comment-1132</guid> <description>On #24 you can eliminate the type attribute as well.
“There is no need to use the language or type attributes. It is the server, not the script tag, that determines the MIME type. ”
( &lt;a href=&quot;http://javascript.crockford.com/code.html&quot; rel=&quot;nofollow&quot;&gt;http://javascript.crockford.com/code.html&lt;/a&gt;).
关于24条，type属性也能省略掉。
“没必要设置language或者type属性，这是服务器该做的事，应该由服务器指定JS文件的MIME类型。”</description> <content:encoded><![CDATA[<p>On #24 you can eliminate the type attribute as well.<br
/> “There is no need to use the language or type attributes. It is the server, not the script tag, that determines the MIME type. ”<br
/> ( <a
href="http://javascript.crockford.com/code.html" rel="nofollow">http://javascript.crockford.com/code.html</a>).</p><p>关于24条，type属性也能省略掉。<br
/> “没必要设置language或者type属性，这是服务器该做的事，应该由服务器指定JS文件的MIME类型。”</p> ]]></content:encoded> </item> </channel> </rss>
