<?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: How to do a non-destructive overwrite of a function in javascript</title>
	<atom:link href="http://www.javascriptkata.com/2007/05/03/how-to-do-a-non-destructive-overwrite-of-a-function-in-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javascriptkata.com/2007/05/03/how-to-do-a-non-destructive-overwrite-of-a-function-in-javascript/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-do-a-non-destructive-overwrite-of-a-function-in-javascript</link>
	<description>helping you with javascript since 2007</description>
	<lastBuildDate>Tue, 31 Jan 2012 11:22:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Irimaniumnops</title>
		<link>http://www.javascriptkata.com/2007/05/03/how-to-do-a-non-destructive-overwrite-of-a-function-in-javascript/comment-page-1/#comment-1387</link>
		<dc:creator>Irimaniumnops</dc:creator>
		<pubDate>Thu, 13 Oct 2011 11:55:09 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=36#comment-1387</guid>
		<description>&lt;strong&gt;Sources...&lt;/strong&gt;

[...]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[...]…...</description>
		<content:encoded><![CDATA[<p><strong>Sources&#8230;</strong></p>
<p>[...]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[...]…&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens</title>
		<link>http://www.javascriptkata.com/2007/05/03/how-to-do-a-non-destructive-overwrite-of-a-function-in-javascript/comment-page-1/#comment-1057</link>
		<dc:creator>Jens</dc:creator>
		<pubDate>Tue, 23 Nov 2010 02:03:12 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=36#comment-1057</guid>
		<description>Thank you very much for that piece of code! I spent quite some time to find a solution how to extend some of Javascript&#039;s built-in functions without simply overwriting it.</description>
		<content:encoded><![CDATA[<p>Thank you very much for that piece of code! I spent quite some time to find a solution how to extend some of Javascript&#39;s built-in functions without simply overwriting it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Potherca</title>
		<link>http://www.javascriptkata.com/2007/05/03/how-to-do-a-non-destructive-overwrite-of-a-function-in-javascript/comment-page-1/#comment-953</link>
		<dc:creator>Potherca</dc:creator>
		<pubDate>Fri, 27 Aug 2010 12:50:09 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=36#comment-953</guid>
		<description>Since you didn&#039;t like the expression &quot;non-destructive overwrite&quot; but couldn’t come up with a better one, you might be interested to know that it is more widely known as &quot;monkey patching&quot; or &quot;duck punching&quot;: &lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Duck_punching&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Duck_punching&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Since you didn&#39;t like the expression &#8220;non-destructive overwrite&#8221; but couldn’t come up with a better one, you might be interested to know that it is more widely known as &#8220;monkey patching&#8221; or &#8220;duck punching&#8221;: </p>
<p><a href="http://en.wikipedia.org/wiki/Duck_punching" rel="nofollow">http://en.wikipedia.org/wiki/Duck_punching</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephan Wehner</title>
		<link>http://www.javascriptkata.com/2007/05/03/how-to-do-a-non-destructive-overwrite-of-a-function-in-javascript/comment-page-1/#comment-478</link>
		<dc:creator>Stephan Wehner</dc:creator>
		<pubDate>Mon, 02 Jun 2008 08:05:44 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=36#comment-478</guid>
		<description>Couldn&#039;t get this to work with &quot;console.debug&quot; (which comes with Firebug, for Firefox) -- I got &quot;too many recursions&quot; with

var origcd = console.debug
console.debug = function(s) { 
  origcd(&#039;console-debug: &#039; + s)
}
:
:
:
console.debug(&#039;test&#039;)

console.debug writes to a console, that can be viewed with Firebug.

Stephan</description>
		<content:encoded><![CDATA[<p>Couldn&#8217;t get this to work with &#8220;console.debug&#8221; (which comes with Firebug, for Firefox) &#8212; I got &#8220;too many recursions&#8221; with</p>
<p>var origcd = console.debug<br />
console.debug = function(s) {<br />
  origcd(&#8216;console-debug: &#8216; + s)<br />
}<br />
:<br />
:<br />
:<br />
console.debug(&#8216;test&#8217;)</p>
<p>console.debug writes to a console, that can be viewed with Firebug.</p>
<p>Stephan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BK</title>
		<link>http://www.javascriptkata.com/2007/05/03/how-to-do-a-non-destructive-overwrite-of-a-function-in-javascript/comment-page-1/#comment-198</link>
		<dc:creator>BK</dc:creator>
		<pubDate>Tue, 22 May 2007 14:11:39 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=36#comment-198</guid>
		<description>What do you mean by DOM Level 2?
Are you talking about the register event stuff?</description>
		<content:encoded><![CDATA[<p>What do you mean by DOM Level 2?<br />
Are you talking about the register event stuff?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Craig</title>
		<link>http://www.javascriptkata.com/2007/05/03/how-to-do-a-non-destructive-overwrite-of-a-function-in-javascript/comment-page-1/#comment-197</link>
		<dc:creator>James Craig</dc:creator>
		<pubDate>Sat, 19 May 2007 20:31:24 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=36#comment-197</guid>
		<description>Even without a library, try DOM Level 2 assignment and you won&#039;t overwrite any of these DOM 1 assignments or other DOM 2 events.</description>
		<content:encoded><![CDATA[<p>Even without a library, try DOM Level 2 assignment and you won&#8217;t overwrite any of these DOM 1 assignments or other DOM 2 events.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Becker</title>
		<link>http://www.javascriptkata.com/2007/05/03/how-to-do-a-non-destructive-overwrite-of-a-function-in-javascript/comment-page-1/#comment-196</link>
		<dc:creator>Scott Becker</dc:creator>
		<pubDate>Mon, 07 May 2007 20:07:30 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=36#comment-196</guid>
		<description>Since you&#039;re not really overwriting the function, but adding before and after callbacks, ActsAsAspect is an elegant way of doing this - http://beppu.lbox.org/articles/2006/09/06/actsasaspect

Basically, you can take a function or object or class with some existing methods:

  MyObj.go = function() { alert(&#039;go&#039;); }

and call actsAsAspect() on it like so:

  actsAsAspect(MyObj);

then it gets some some extra methods - before, after, &amp; around, which let you add listeners to that function like this:

MyObj.before(&#039;go&#039;, function() { alert(&#039;do this before go() gets called!&#039;) })

It&#039;s short and sweet, I love that little script.</description>
		<content:encoded><![CDATA[<p>Since you&#8217;re not really overwriting the function, but adding before and after callbacks, ActsAsAspect is an elegant way of doing this &#8211; <a href="http://beppu.lbox.org/articles/2006/09/06/actsasaspect" rel="nofollow">http://beppu.lbox.org/articles/2006/09/06/actsasaspect</a></p>
<p>Basically, you can take a function or object or class with some existing methods:</p>
<p>  MyObj.go = function() { alert(&#8216;go&#8217;); }</p>
<p>and call actsAsAspect() on it like so:</p>
<p>  actsAsAspect(MyObj);</p>
<p>then it gets some some extra methods &#8211; before, after, &amp; around, which let you add listeners to that function like this:</p>
<p>MyObj.before(&#8216;go&#8217;, function() { alert(&#8216;do this before go() gets called!&#8217;) })</p>
<p>It&#8217;s short and sweet, I love that little script.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: si</title>
		<link>http://www.javascriptkata.com/2007/05/03/how-to-do-a-non-destructive-overwrite-of-a-function-in-javascript/comment-page-1/#comment-195</link>
		<dc:creator>si</dc:creator>
		<pubDate>Fri, 04 May 2007 21:34:04 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=36#comment-195</guid>
		<description>While I don&#039;t like that method of event adding (I think a nice cross-browser addEvent function is far safer / nicer), it&#039;s quite a pretty way of doing it - one good consequence is that you can specify whether yours happens before or after all of the existing methods.

Another similar &quot;trick&quot; which I like is overriding the alert() function to get rid of potentially missed debug code, like so:

_alert = alert;
alert = null;</description>
		<content:encoded><![CDATA[<p>While I don&#8217;t like that method of event adding (I think a nice cross-browser addEvent function is far safer / nicer), it&#8217;s quite a pretty way of doing it &#8211; one good consequence is that you can specify whether yours happens before or after all of the existing methods.</p>
<p>Another similar &#8220;trick&#8221; which I like is overriding the alert() function to get rid of potentially missed debug code, like so:</p>
<p>_alert = alert;<br />
alert = null;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.javascriptkata.com/2007/05/03/how-to-do-a-non-destructive-overwrite-of-a-function-in-javascript/comment-page-1/#comment-194</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Fri, 04 May 2007 14:14:11 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=36#comment-194</guid>
		<description>@Boyan
I guess that a lot of librairies can take care of this... but sometimes you don&#039;t have any librairie for a small web site or a bookmarklet...

Thanks for the correction...</description>
		<content:encoded><![CDATA[<p>@Boyan<br />
I guess that a lot of librairies can take care of this&#8230; but sometimes you don&#8217;t have any librairie for a small web site or a bookmarklet&#8230;</p>
<p>Thanks for the correction&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Boyan</title>
		<link>http://www.javascriptkata.com/2007/05/03/how-to-do-a-non-destructive-overwrite-of-a-function-in-javascript/comment-page-1/#comment-193</link>
		<dc:creator>Boyan</dc:creator>
		<pubDate>Fri, 04 May 2007 13:38:29 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=36#comment-193</guid>
		<description>Nice. Don&#039;t most js libraries take care of this automatically already? Oh, and by the way (nitpick coming), the past tense of &quot;stick&quot; is &quot;stuck&quot; and not &quot;stucked&quot;</description>
		<content:encoded><![CDATA[<p>Nice. Don&#8217;t most js libraries take care of this automatically already? Oh, and by the way (nitpick coming), the past tense of &#8220;stick&#8221; is &#8220;stuck&#8221; and not &#8220;stucked&#8221;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

