Alan Niederauer

Greenhorn
+ Follow
since Sep 27, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Alan Niederauer

The constructor GUARANTEES that any initialization code gets called. This frees you from having to explicitly call such code each time you create an object. Also, this means anyone else that creates one of your objects doesn't have to call intialization code. You can create several constructors which allows you the flexibility to default certain values. You can create a constructor where the user has to pass in all the initialization parameters -- i.e.,
myObject(a, b, c, d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
You can create a constructor where none of the values are passed and you default all of them. i.e.,
myObject() {
this.a = 1;
this.b = 2;
this.c = 3;
this.d = 4;
}
And of course you can do something inbetween where only some of the parameters are passed to the constructor:
myObject(a, c) {
this.a = a;
this.b = 2;
this.c = c;
this.d = 4;
}
23 years ago
Where do I find out more about XML certification?
Where do I find out more about XML certification?
Where do I find out more about XML certification?