<?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: Lazy definition function</title>
	<atom:link href="http://www.jspatterns.com/lazy-definition-function/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jspatterns.com/lazy-definition-function/</link>
	<description>Exploring common JavaScript patterns and anti-patterns</description>
	<pubDate>Wed, 08 Sep 2010 21:01:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5-RC1</generator>
		<item>
		<title>By: Rob</title>
		<link>http://www.jspatterns.com/lazy-definition-function/#comment-2585</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Mon, 19 Apr 2010 21:59:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.jspatterns.com/?p=66#comment-2585</guid>
		<description>This pattern can be useful when dealing with cross-browser code. For instance, getting the XmlHttpRequest() object. You could wrap the code for searching the correct object in the initial code and return the caching of the final object. Like this for instance:

ns.getXHRObject = function() {

  if (typeof(window.XMLHttpRequest) === "function") {
    // Native object exists
    ns.getXHRObject = function() {
                                return new window.XMLHttpRequest();
                              };
  }
  else {
    // Do your older browser searching here and replace the outcome with
    // a similar new function definition as above..
  }
};

Next time the function is called, the caching is returned. So execution will be faster the
second time.. imagine doing this for functions which will do lots of logic over and over again with the same outcome.. this can save lots of cpu cycles.. and better yet, improve user experience..</description>
		<content:encoded><![CDATA[<p>This pattern can be useful when dealing with cross-browser code. For instance, getting the XmlHttpRequest() object. You could wrap the code for searching the correct object in the initial code and return the caching of the final object. Like this for instance:</p>
<p>ns.getXHRObject = function() {</p>
<p>  if (typeof(window.XMLHttpRequest) === &#8220;function&#8221;) {<br />
    // Native object exists<br />
    ns.getXHRObject = function() {<br />
                                return new window.XMLHttpRequest();<br />
                              };<br />
  }<br />
  else {<br />
    // Do your older browser searching here and replace the outcome with<br />
    // a similar new function definition as above..<br />
  }<br />
};</p>
<p>Next time the function is called, the caching is returned. So execution will be faster the<br />
second time.. imagine doing this for functions which will do lots of logic over and over again with the same outcome.. this can save lots of cpu cycles.. and better yet, improve user experience..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yaroslav</title>
		<link>http://www.jspatterns.com/lazy-definition-function/#comment-2411</link>
		<dc:creator>Yaroslav</dc:creator>
		<pubDate>Mon, 29 Mar 2010 10:57:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.jspatterns.com/?p=66#comment-2411</guid>
		<description>What is the difference between lazy definition functions and closures? They looks too similar.</description>
		<content:encoded><![CDATA[<p>What is the difference between lazy definition functions and closures? They looks too similar.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 澄净的禅院 &#187; Blog Archive &#187; Lazy Function Definition</title>
		<link>http://www.jspatterns.com/lazy-definition-function/#comment-2294</link>
		<dc:creator>澄净的禅院 &#187; Blog Archive &#187; Lazy Function Definition</dc:creator>
		<pubDate>Thu, 18 Mar 2010 14:41:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.jspatterns.com/?p=66#comment-2294</guid>
		<description>[...] http://www.jspatterns.com/lazy-definition-function/ [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] <a href="http://www.jspatterns.com/lazy-definition-function/" rel="nofollow">http://www.jspatterns.com/lazy-definition-function/</a> [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nghia</title>
		<link>http://www.jspatterns.com/lazy-definition-function/#comment-2018</link>
		<dc:creator>nghia</dc:creator>
		<pubDate>Mon, 18 Jan 2010 14:27:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.jspatterns.com/?p=66#comment-2018</guid>
		<description>Hi Stoyan Stefanov
please answer me a question : What is Lazy definition function used for? and when we use it ?</description>
		<content:encoded><![CDATA[<p>Hi Stoyan Stefanov<br />
please answer me a question : What is Lazy definition function used for? and when we use it ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
