JavaScript let's you do proper encapsulation using closures like so:
function Person(name) {
this.setName = function(value) {
name = value;
}
this.getName = function() {
return name;
}
}
There's a memory cost to this, though: every instance of the Person
class will get it's own
Thanks for the replies guys.
Sometimes JS's flexibility can catch me out. I guess there is no right
or wrong way to do anything. Just things to consider.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Prototype
On Mar 9, 9:50 am, webbear1000 normpo...@hotmail.com wrote:
I'm interested in your opinions on how I'm handling getters and
setters in classes. Can you see any problems with my approach and what
trouble might I be getting myself into?
The huge body of my programming work has been with