thanks Julian and Duncan for you solutions, didn't know you could do
such crazy things with this language!!
in my case the problem is i want to distinguish between private <->
public AND define the methods for an object outside of the consructor (
because [as stated in the first post of this thread] i have to create
many instances of this class.
but i guess after reading your solutions and trying a few things this is
not so easy (if not impossible). i'm not into javascript for very long,
my mind is still thinking in java-terms ..
the solution for me is to give up on seperating private and public, just
use some naming conventions for pseudo-private things and make
everything public like this:
item = function () {
this._privateFieldA = 0;
this._privateFieldB = 0;
this._privateFieldC = 0;
..
}
item.prototype.manipulateA = function() {
this._privateFieldA++;
}
var myObj = new item();
and using the object like myObj.manipulateA() [even if it could be done
using myObj._privateFieldA++]
thanks for you effort guys!
-
Gerald Stampfel