<?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: Hi-performance Javascript Tips #1 [Updated 2009-03-19]</title>
	<atom:link href="http://unscriptable.com/index.php/2009/03/19/hi-performance-javascript-tips-1/feed/" rel="self" type="application/rss+xml" />
	<link>http://unscriptable.com/index.php/2009/03/19/hi-performance-javascript-tips-1/</link>
	<description>Nothing is impossible.  Even on the Web.</description>
	<lastBuildDate>Mon, 28 Jun 2010 22:12:59 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: John Hann</title>
		<link>http://unscriptable.com/index.php/2009/03/19/hi-performance-javascript-tips-1/comment-page-1/#comment-434</link>
		<dc:creator>John Hann</dc:creator>
		<pubDate>Fri, 20 Mar 2009 01:17:52 +0000</pubDate>
		<guid isPermaLink="false">http://unscriptable.com/?p=108#comment-434</guid>
		<description>Hey kangax,

&lt;blockquote&gt;There’s really no need to pass `window` to self-executing function  Remember that `this` always refers to a global object when function is called as a function (at least in ES3). &lt;/blockquote&gt;

Drat!  That&#039;s what happens when you commit code at 2 AM after a 2 beers.  I was going to discuss using the anonymous function parameters as another method of bringing variables into scope without polluting the outer scope.  But I decided to cut the post short and shoved that craziness in there anyways.


&lt;blockquote&gt;I also don’t see a reason to create an array just to use its `slice`. &lt;/blockquote&gt;

I was trying to see how few characters I could use.  [] is much shorter than Array.prototype, but of course comes at the cost of an object construction.

&lt;blockquote&gt;Besides, why resolve `slice` property lookup on `_a` (every time function is called) when you can store it as it is:&lt;/blockquote&gt;

/me blames it on the beers. :-P



&lt;blockquote&gt;var toArray = (function(slice){
return function toArray(object) {
return slice.call(object, 0);
}
})(Array.prototype.slice);&lt;/blockquote&gt;

Awesomeness all around. Thx! I will update my post!</description>
		<content:encoded><![CDATA[<p>Hey kangax,</p>
<blockquote><p>There’s really no need to pass `window` to self-executing function  Remember that `this` always refers to a global object when function is called as a function (at least in ES3). </p></blockquote>
<p>Drat!  That&#8217;s what happens when you commit code at 2 AM after a 2 beers.  I was going to discuss using the anonymous function parameters as another method of bringing variables into scope without polluting the outer scope.  But I decided to cut the post short and shoved that craziness in there anyways.</p>
<blockquote><p>I also don’t see a reason to create an array just to use its `slice`. </p></blockquote>
<p>I was trying to see how few characters I could use.  [] is much shorter than Array.prototype, but of course comes at the cost of an object construction.</p>
<blockquote><p>Besides, why resolve `slice` property lookup on `_a` (every time function is called) when you can store it as it is:</p></blockquote>
<p>/me blames it on the beers. <img src='http://unscriptable.com/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
<blockquote><p>var toArray = (function(slice){<br />
return function toArray(object) {<br />
return slice.call(object, 0);<br />
}<br />
})(Array.prototype.slice);</p></blockquote>
<p>Awesomeness all around. Thx! I will update my post!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kangax</title>
		<link>http://unscriptable.com/index.php/2009/03/19/hi-performance-javascript-tips-1/comment-page-1/#comment-431</link>
		<dc:creator>kangax</dc:creator>
		<pubDate>Thu, 19 Mar 2009 15:10:26 +0000</pubDate>
		<guid isPermaLink="false">http://unscriptable.com/?p=108#comment-431</guid>
		<description>There&#039;s really no need to pass `window` to self-executing function :) Remember that `this` always refers to a global object when function is called as a function (at least in ES3). I also don&#039;t see a reason to create an array just to use its `slice`. Besides, why resolve `slice` property lookup on `_a` (every time function is called) when you can store it as it is:

(function(){
  _slice = Array.prototype.slice;
  this.toArray = function(object) {
    return _slice.call(object, 0);
  }
})();

We can, of course, shorten this up a bit:

var toArray = (function(slice){
  return function(object) {
    return slice.call(object, 0);
  }
})(Array.prototype.slice);

It&#039;s also a good idea to give function a descriptive identifier (for debugging purposes):

var toArray = (function(slice){
  return function toArray(object) {
    return slice.call(object, 0);
  }
})(Array.prototype.slice);</description>
		<content:encoded><![CDATA[<p>There&#8217;s really no need to pass `window` to self-executing function <img src='http://unscriptable.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Remember that `this` always refers to a global object when function is called as a function (at least in ES3). I also don&#8217;t see a reason to create an array just to use its `slice`. Besides, why resolve `slice` property lookup on `_a` (every time function is called) when you can store it as it is:</p>
<p>(function(){<br />
  _slice = Array.prototype.slice;<br />
  this.toArray = function(object) {<br />
    return _slice.call(object, 0);<br />
  }<br />
})();</p>
<p>We can, of course, shorten this up a bit:</p>
<p>var toArray = (function(slice){<br />
  return function(object) {<br />
    return slice.call(object, 0);<br />
  }<br />
})(Array.prototype.slice);</p>
<p>It&#8217;s also a good idea to give function a descriptive identifier (for debugging purposes):</p>
<p>var toArray = (function(slice){<br />
  return function toArray(object) {<br />
    return slice.call(object, 0);<br />
  }<br />
})(Array.prototype.slice);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hi-Performance Javascript Tip #2 Revisited &#124; Unscriptable.com</title>
		<link>http://unscriptable.com/index.php/2009/03/19/hi-performance-javascript-tips-1/comment-page-1/#comment-430</link>
		<dc:creator>Hi-Performance Javascript Tip #2 Revisited &#124; Unscriptable.com</dc:creator>
		<pubDate>Thu, 19 Mar 2009 13:58:34 +0000</pubDate>
		<guid isPermaLink="false">http://unscriptable.com/?p=108#comment-430</guid>
		<description>[...] toArray [...]</description>
		<content:encoded><![CDATA[<p>[...] toArray [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
