# Trying to understand prototypes

**URL:** <https://forum.kirupa.com/t/trying-to-understand-prototypes/97602>\
**Category:** Uncategorized\
**Created:** [December 25, 2003, 1:58pm UTC](https://forum.kirupa.com/t/trying-to-understand-prototypes/97602 "2003-12-25T13:58:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kO2n](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ko2n/32/248_2.png) [@kO2n](https://forum.kirupa.com/u/kO2n)\
**Post date:** [December 25, 2003, 1:58pm UTC](https://forum.kirupa.com/t/trying-to-understand-prototypes/97602/1 "2003-12-25T13:58:10Z")

</div>

Whats the difference between the following two bits of code:

[AS]  
Dog = function( )  
{  
this.legs = 4;  
}  
rover = new Dog( );  
fido = new Dog( );  
yeller = new Dog( );  
[/AS]  
AND  
[AS]  
Dog = function( ){}  
Dog.prototype.legs = 4;

rover = new Dog( );  
fido = new Dog( );  
yeller = new Dog( );  
[/AS]

Is one better than the other? If so, how?  
Can’t get my head around it!?

Viru.
