function Model(option){
this.name = option ? option.name : '';
this.age = option ? option.age : 0;
this.year = option ? option.year : 0;
this.examsTaken = option ? option.examsTaken : 0;
this.takeExam = option ? option.takeExam : function() {};
this.changed = option ? option.changed : false;
return this;
}
this.name = '';
this.age = 0;
this.year = 0;
// ...
for (var x in options) {
if (options.hasOwnProperty(x)) {
this[x] = options[x];
}
}
this.name = '';
this.age = 0;
this.year = 0;
var availableOptions = ['name', 'age', 'year'];
// ...
for (var i = 0; i < availableOptions.length; i ++) {
var x = availableOptions[i];
if (options.hasOwnProperty(x)) {
this[x] = options[x];
}
}