<?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: Javascript cloning objects</title>
	<atom:link href="http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/</link>
	<description>A tool for designers dealing with programmers dealing with designers...</description>
	<pubDate>Wed, 09 Jul 2008 02:53:00 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Mikael Grave</title>
		<link>http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1220</link>
		<dc:creator>Mikael Grave</dc:creator>
		<pubDate>Fri, 09 May 2008 17:29:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1220</guid>
		<description>Your eval/uneval idea inspired me a cross-browser solution for those using YUI:

function clone = function( obj ) {
  return YAHOO.lang.JSON.parse( YAHOO.lang.JSON.stringify( obj ) );
}

Tested fine with IE6 and FF2. Especially convenient for cloning arrays, hashs of arrays, arrays of hashs, etc.

Not sure about the performances. Might slow down your app if used to massively clone objects...</description>
		<content:encoded><![CDATA[<p>Your eval/uneval idea inspired me a cross-browser solution for those using YUI:</p>
<p>function clone = function( obj ) {<br />
  return YAHOO.lang.JSON.parse( YAHOO.lang.JSON.stringify( obj ) );<br />
}</p>
<p>Tested fine with IE6 and FF2. Especially convenient for cloning arrays, hashs of arrays, arrays of hashs, etc.</p>
<p>Not sure about the performances. Might slow down your app if used to massively clone objects&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kymin</title>
		<link>http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1205</link>
		<dc:creator>kymin</dc:creator>
		<pubDate>Sun, 20 Apr 2008 18:38:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1205</guid>
		<description>Have you not about c &#38; c++ 's book ?
Post my E-mail,thank you</description>
		<content:encoded><![CDATA[<p>Have you not about c &amp; c++ &#8217;s book ?<br />
Post my E-mail,thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gareth Heyes</title>
		<link>http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1202</link>
		<dc:creator>Gareth Heyes</dc:creator>
		<pubDate>Thu, 10 Apr 2008 17:19:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1202</guid>
		<description>@kourge

Nice tip and good point</description>
		<content:encoded><![CDATA[<p>@kourge</p>
<p>Nice tip and good point</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kourge</title>
		<link>http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1201</link>
		<dc:creator>kourge</dc:creator>
		<pubDate>Thu, 10 Apr 2008 17:08:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1201</guid>
		<description>It is bad practice to mingle with Object.prototype because it messes up property enumeration. Just google "Object.prototype is verboten" and a zillion arguments will appear. The Prototype JavaScript library once did this in 1.3 - with bad results.
The fix is to instead tack methods on to the global Object. For example:
Object.clone = function(object) { return eval(uneval(object)); };</description>
		<content:encoded><![CDATA[<p>It is bad practice to mingle with Object.prototype because it messes up property enumeration. Just google &#8220;Object.prototype is verboten&#8221; and a zillion arguments will appear. The Prototype JavaScript library once did this in 1.3 - with bad results.<br />
The fix is to instead tack methods on to the global Object. For example:<br />
Object.clone = function(object) { return eval(uneval(object)); };</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gareth Heyes</title>
		<link>http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1200</link>
		<dc:creator>Gareth Heyes</dc:creator>
		<pubDate>Thu, 10 Apr 2008 12:43:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1200</guid>
		<description>@pdp

Damn I thought it worked in IE7 ah well neat trick anyways</description>
		<content:encoded><![CDATA[<p>@pdp</p>
<p>Damn I thought it worked in IE7 ah well neat trick anyways</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pdp</title>
		<link>http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1199</link>
		<dc:creator>pdp</dc:creator>
		<pubDate>Thu, 10 Apr 2008 11:05:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1199</guid>
		<description>of course that works with FF and a few other browsers only. The more universal way of doing the same is exactly what I used in CoreAPI: http://www.gnucitizen.org/projects/coreapi/

CoreAPI.clone = function (o) {
	function c(o) {
		for (var i in o) {
			this[i] = o[i];
		}
	}

	return new c(o);
};</description>
		<content:encoded><![CDATA[<p>of course that works with FF and a few other browsers only. The more universal way of doing the same is exactly what I used in CoreAPI: <a href="http://www.gnucitizen.org/projects/coreapi/" rel="nofollow">http://www.gnucitizen.org/projects/coreapi/</a></p>
<p>CoreAPI.clone = function (o) {<br />
	function c(o) {<br />
		for (var i in o) {<br />
			this[i] = o[i];<br />
		}<br />
	}</p>
<p>	return new c(o);<br />
};</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hakan Bilgin</title>
		<link>http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1198</link>
		<dc:creator>Hakan Bilgin</dc:creator>
		<pubDate>Thu, 10 Apr 2008 09:54:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.thespanner.co.uk/2008/04/10/javascript-cloning-objects/#comment-1198</guid>
		<description>Hi Gareth,
Great tips! Unfortunately, if the object contains a reference to an HTML or XML element, those references is not cloned (of course). Which in turn makes this solution a little inadequate.

Yet, thanx for the trick!</description>
		<content:encoded><![CDATA[<p>Hi Gareth,<br />
Great tips! Unfortunately, if the object contains a reference to an HTML or XML element, those references is not cloned (of course). Which in turn makes this solution a little inadequate.</p>
<p>Yet, thanx for the trick!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
