Question about making a property on custom object
- From: "Sam Kong" <sam.s.kong@xxxxxxxxx>
- Date: 9 Jan 2006 12:03:02 -0800
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
.
- Follow-Ups:
- Re: Question about making a property on custom object
- From: zwetan
- Re: Question about making a property on custom object
- From: Thomas 'PointedEars' Lahn
- Re: Question about making a property on custom object
- Prev by Date: Re: Looking for Special Calendar
- Next by Date: Re: How do we get the iframe window size?
- Previous by thread: Looking for Special Calendar
- Next by thread: Re: Question about making a property on custom object
- Index(es):
Relevant Pages
|