I\'m using Backbone.js for the first time, and liking it so far. One thing I can\'t work out at the moment in dynamic attributes of models. For example, say I have a Person
I would think of attributes as the raw materials used by a model to provide answers to callers that ask the questions. I actually don't like having callers know too much about the internal attribute structure. Its an implementation detail. What if this structure changes?
So my answer would be: don't do it.
Create a method as you've done and hide the implementation details. Its much cleaner code and survives implementation changes.