Will wrote:
> Is it possible to have private instance members in a javascript class?
No, and unless you are talking about JavaScript 2.0 there are no classes
in JavaScript. The below declares and defines a constructor function
for a prototype object and therefore that object itself.
> function myObject() {
> var private = 1;
>
> this.getPrivate = function() {
> return private;
> }
>
> this.incrementPrivate = function() {
> private += 1;
> }
> }
>
> var a = new myObject();
> var b = new myObject();
> a.incrementPrivate();
The `new' operator creates a new object based on the prototype
object (inheriting its properties) and returns a reference to
that object which you assign to variables here, making their
identifiers object references on which the lookup operator `.'
can be applied.
Since in prototype-based languages like JavaScript 1.x every
object is an `instance', it is better to avoid that term there
to avoid confusion.
See
http://devedge.netscape.com/library/...2.html#1008342
PointedEars