person = {
name: "ryan to",
first: function() {
return this.name.split(/\s/)[0];
},
last: function() {
return this.name.split(/\s/)[1];
}
}
But you realize this could be harmful, so you want to change it to: person = {
name: function() {
return this.first + " " + this.last;
},
first: "ryan",
last: "to"
}
All of a sudden your code breaks because person.name needs to become person.name(), person.first() to person.first, etc. That is somewhat hard to track down/refactor in a large JavaScript code base, or any dynamic language code base for that matter.Uniform access principle is, in my opinion, one of the selling points for implementing your own object model in JS.