Question about making a property on custom object



Hello!

I got recently intrigued with JavaScript's prototype-based
object-orientation.
However, I still don't understand the mechanism clearly.

[Q1]
What's the difference between the following two?

(1)
function C(){
this.name = "Unknown"
}

(2)
function C(){
}
C.prototype.name = "Unknown"



[Q2]
There's no notion of Class in JavaScript and everything is an object.
How many objects are created in the following code including the
objects implicitly created in the behind?

function C(){
}

function D(){
}
D.prototype = new C

var obj = new D


[Q3]
I saw some codes like "this.base = SomeClass".
When is it needed?
Is it different from ClassName.prototype = new ParentClassName?


[Q4]
What's the difference between prototype and __proto__?


Thanks in advance.
Sam

.



Relevant Pages

  • Re: Help with solutions to two DEs
    ... *slaps his forehead* oops, I just completely looked over how to solve ... for the second DE, thanks for that hint. ... Sam J. ... Prev by Date: ...
    (sci.math)
  • Run code on new record
    ... not execute, making me think that my plan is no good. ... Prev by Date: ...
    (microsoft.public.access.modulesdaovba)
  • Re: rgcp controversy about Larry Parr
    ... > and would deserve our sympathy. ... Sam used to go to out-of-town tournaments and share a room and a ... Prev by Date: ...
    (rec.games.chess.politics)
  • Re: Lost - Ch4
    ... Considering that when ER started my younger child was barely 2 and my elder ... just at the initial-fabrication stage, ... SAm. ... Prev by Date: ...
    (uk.media.tv.misc)