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];
}
}