Subj : Theoretical question about 'prototype'. To : netscape.public.mozilla.jseng From : Andrew Fedoniouk Date : Thu Dec 30 2004 11:18 pm Hi, I've almost done with my own JS engine and think that this is a right time to ask one question bothering me during design time :) Let's say we have a function which we are going to use as ctor for our new class: function Foo() { this.a = 1; } then after creating new object: var foo = new Foo(); in foo we have an instance of Object with [[Prototype]] set to Foo.prototype. or foo.[[Prototype]] === Foo.prototype; The question is : why not to use Foo itself as such prototype object? Foo as an object can also hold properties as any other so theoretically it can serve as a prototype. In other words: why we need to create special Foo.prototype property and use it as a 'parent' of instances created using new Foo() calls if we can set 'parent' ([[Prototype]]) reference to Foo itself? Imagine that after execution of foo = new Foo(); we will have: foo.[[Prototype]] === Foo Using such assumption we can build the same 'class rack' as with the 'prototype': Like: Foo.get_a = function() { return this.a; } and call it as foo.get_a() with the same result. It seems for me that schema with foo.[[Prototype]] === Foo.prototype introduced needless entities. Probably I've missed something serious.... In hope to find answer and thanks in advance, Andrew Fedoniouk. http://terrainformatica.com .