Slide 14
Slide 14 text
...
set: function (key, val) {
var data;
if (key == null) return this;
// Handle both `key, value` and `{key: value}` style arguments.
if (typeof key === 'object') {
data = key;
} else {
(data = {})[key] = val;
}
_.each(data, function(value, key) {
if (_.isUndefined(attrs[key])) {
attrs[key] = value;
} else {
console.warn("You're not supposed to change this value.");
}
});
},
toJSON: function() {
return _.clone(attrs);
}
...