<?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 create objects in object-oriented javascript</title>
	<atom:link href="http://www.javascriptkata.com/2007/03/23/how-to-create-objects-in-object-oriented-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javascriptkata.com/2007/03/23/how-to-create-objects-in-object-oriented-javascript/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-create-objects-in-object-oriented-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: Parminavilum</title>
		<link>http://www.javascriptkata.com/2007/03/23/how-to-create-objects-in-object-oriented-javascript/comment-page-1/#comment-1378</link>
		<dc:creator>Parminavilum</dc:creator>
		<pubDate>Thu, 13 Oct 2011 01:22:04 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=11#comment-1378</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: dYcbbgcx</title>
		<link>http://www.javascriptkata.com/2007/03/23/how-to-create-objects-in-object-oriented-javascript/comment-page-1/#comment-1377</link>
		<dc:creator>dYcbbgcx</dc:creator>
		<pubDate>Thu, 13 Oct 2011 00:58:41 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=11#comment-1377</guid>
		<description>&lt;strong&gt;2011...&lt;/strong&gt;

Good write-up, I’m regular visitor of one’s blog, maintain up the excellent operate, and It&#039;s going to be a regular visitor for a lengthy time....</description>
		<content:encoded><![CDATA[<p><strong>2011&#8230;</strong></p>
<p>Good write-up, I’m regular visitor of one’s blog, maintain up the excellent operate, and It&#8217;s going to be a regular visitor for a lengthy time&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexwebmaster</title>
		<link>http://www.javascriptkata.com/2007/03/23/how-to-create-objects-in-object-oriented-javascript/comment-page-1/#comment-719</link>
		<dc:creator>Alexwebmaster</dc:creator>
		<pubDate>Tue, 03 Mar 2009 10:37:45 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=11#comment-719</guid>
		<description>Hello webmaster 
I would like to share with you a link to your site 
write me here preonrelt@mail.ru</description>
		<content:encoded><![CDATA[<p>Hello webmaster<br />
I would like to share with you a link to your site<br />
write me here <a href="mailto:preonrelt@mail.ru">preonrelt@mail.ru</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How to make a singleton in javascript &#124; Javascript Kata</title>
		<link>http://www.javascriptkata.com/2007/03/23/how-to-create-objects-in-object-oriented-javascript/comment-page-1/#comment-681</link>
		<dc:creator>How to make a singleton in javascript &#124; Javascript Kata</dc:creator>
		<pubDate>Tue, 02 Dec 2008 16:01:28 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=11#comment-681</guid>
		<description>[...] writing a singleton, you need to know about creating objects and static [...]</description>
		<content:encoded><![CDATA[<p>[...] writing a singleton, you need to know about creating objects and static [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Sazonov</title>
		<link>http://www.javascriptkata.com/2007/03/23/how-to-create-objects-in-object-oriented-javascript/comment-page-1/#comment-26</link>
		<dc:creator>Andrew Sazonov</dc:creator>
		<pubDate>Tue, 01 May 2007 16:35:25 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=11#comment-26</guid>
		<description>Yes, approach described in the post works. But unfortunately, it is far from being perfect...

Here is a link to an article which compares various techniques to implement inheritance in JavaScript (and their benefits and drawbacks):

http://www.soft-amis.org/jsiner/inheritance.html</description>
		<content:encoded><![CDATA[<p>Yes, approach described in the post works. But unfortunately, it is far from being perfect&#8230;</p>
<p>Here is a link to an article which compares various techniques to implement inheritance in JavaScript (and their benefits and drawbacks):</p>
<p><a href="http://www.soft-amis.org/jsiner/inheritance.html" rel="nofollow">http://www.soft-amis.org/jsiner/inheritance.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How to Create Objects in Object-Oriented JavaScript with Prototype</title>
		<link>http://www.javascriptkata.com/2007/03/23/how-to-create-objects-in-object-oriented-javascript/comment-page-1/#comment-25</link>
		<dc:creator>How to Create Objects in Object-Oriented JavaScript with Prototype</dc:creator>
		<pubDate>Sun, 29 Apr 2007 12:45:24 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=11#comment-25</guid>
		<description>[...] Kata has a teriffic an article on how to create objects with JavaScript the old fashion way, without any JavaScript libraries. But I use prototype and it has its very own [...]</description>
		<content:encoded><![CDATA[<p>[...] Kata has a teriffic an article on how to create objects with JavaScript the old fashion way, without any JavaScript libraries. But I use prototype and it has its very own [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.javascriptkata.com/2007/03/23/how-to-create-objects-in-object-oriented-javascript/comment-page-1/#comment-24</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Wed, 11 Apr 2007 20:43:06 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=11#comment-24</guid>
		<description>Yeah! Jim&#039;s approach looks good but it can be hard to understand for beginners. I&#039;ll try to write about it in a near future...</description>
		<content:encoded><![CDATA[<p>Yeah! Jim&#8217;s approach looks good but it can be hard to understand for beginners. I&#8217;ll try to write about it in a near future&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Mercer</title>
		<link>http://www.javascriptkata.com/2007/03/23/how-to-create-objects-in-object-oriented-javascript/comment-page-1/#comment-22</link>
		<dc:creator>David Mercer</dc:creator>
		<pubDate>Wed, 11 Apr 2007 15:46:43 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=11#comment-22</guid>
		<description>I wrote:

&gt; My preferred approach is more along the lines of:

&gt; function Cat.prototype.meow(){â€¦}

As has been pointed out to me, Firefox chokes on this syntax.  I&#039;ve been using WSH to run Javascript, so never tried it in a browser.  It does work in IE, but not Firefox, so my approach is probably out for usage where you do not control script host.

Jim Plush wrote:

&quot;If you want to see pretty classes you could always do this:...&quot;

I like Jim&#039;s approach.</description>
		<content:encoded><![CDATA[<p>I wrote:</p>
<p>&gt; My preferred approach is more along the lines of:</p>
<p>&gt; function Cat.prototype.meow(){â€¦}</p>
<p>As has been pointed out to me, Firefox chokes on this syntax.  I&#8217;ve been using WSH to run Javascript, so never tried it in a browser.  It does work in IE, but not Firefox, so my approach is probably out for usage where you do not control script host.</p>
<p>Jim Plush wrote:</p>
<p>&#8220;If you want to see pretty classes you could always do this:&#8230;&#8221;</p>
<p>I like Jim&#8217;s approach.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Plush</title>
		<link>http://www.javascriptkata.com/2007/03/23/how-to-create-objects-in-object-oriented-javascript/comment-page-1/#comment-23</link>
		<dc:creator>Jim Plush</dc:creator>
		<pubDate>Wed, 11 Apr 2007 15:31:43 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=11#comment-23</guid>
		<description>I&#039;d have to agree with the author, using prototype over inner functions reduces the memory footprint. I have to work on 233mhz boxes and trust me, every little bit helps.

If you want to see pretty classes you could always do this:

function myClass() {}

myClass.prototype = {

       test:function() {

           alert(&#039;hi&#039;);
       },

       test2:function() {
           // something here
       }
};</description>
		<content:encoded><![CDATA[<p>I&#8217;d have to agree with the author, using prototype over inner functions reduces the memory footprint. I have to work on 233mhz boxes and trust me, every little bit helps.</p>
<p>If you want to see pretty classes you could always do this:</p>
<p>function myClass() {}</p>
<p>myClass.prototype = {</p>
<p>       test:function() {</p>
<p>           alert(&#8216;hi&#8217;);<br />
       },</p>
<p>       test2:function() {<br />
           // something here<br />
       }<br />
};</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Mercer</title>
		<link>http://www.javascriptkata.com/2007/03/23/how-to-create-objects-in-object-oriented-javascript/comment-page-1/#comment-21</link>
		<dc:creator>David Mercer</dc:creator>
		<pubDate>Fri, 30 Mar 2007 21:33:50 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=11#comment-21</guid>
		<description>William Murray wrote:

     &quot;I prefer to assign the methods within the main function...Any advantages or disadvantages to using this over prototype?&quot;

I used to prefer your method, too, but performance is significantly worse with your approach because every time you instantiate an object, a new function is created.

Mind you, most people treat Javascript as kind of a toy language and don&#039;t expect much performance from it, but detach the interpreter from the browser and you can write quite powerful programs with decent performance.

My preferred approach is more along the lines of:

function Cat.prototype.meow(){...}

rather than

Cat.prototype.meow = function(){...}

These work slightly different as functions (and, in this case, methods) declared like mine exist when the first line of the program executes.  Using the &quot;Cat.prototype.meow = function&quot; approach, the method will only exist after the program has executed that line of code.  Thus, my program could begin with the lines:

  var mistigri = new Cat(&#039;Mistigri&#039;);
  mistigri.meow();

Whereas the &quot;Cat.prototype.meow = function&quot; approach would choke on that, since the meow method does not exist yet.</description>
		<content:encoded><![CDATA[<p>William Murray wrote:</p>
<p>     &#8220;I prefer to assign the methods within the main function&#8230;Any advantages or disadvantages to using this over prototype?&#8221;</p>
<p>I used to prefer your method, too, but performance is significantly worse with your approach because every time you instantiate an object, a new function is created.</p>
<p>Mind you, most people treat Javascript as kind of a toy language and don&#8217;t expect much performance from it, but detach the interpreter from the browser and you can write quite powerful programs with decent performance.</p>
<p>My preferred approach is more along the lines of:</p>
<p>function Cat.prototype.meow(){&#8230;}</p>
<p>rather than</p>
<p>Cat.prototype.meow = function(){&#8230;}</p>
<p>These work slightly different as functions (and, in this case, methods) declared like mine exist when the first line of the program executes.  Using the &#8220;Cat.prototype.meow = function&#8221; approach, the method will only exist after the program has executed that line of code.  Thus, my program could begin with the lines:</p>
<p>  var mistigri = new Cat(&#8216;Mistigri&#8217;);<br />
  mistigri.meow();</p>
<p>Whereas the &#8220;Cat.prototype.meow = function&#8221; approach would choke on that, since the meow method does not exist yet.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

