"use strict"
var user = {
name: "Иван",
first: "Степанович",
age: 50
}
Object.defineProperties(user, {
name: {
get: function() {
this.name + "!!!";
}
}
});
alert(user.name);
var user = {
firstName: "Вася",
surname: "Петров"
}
Object.defineProperty(user, "fullName", {
get: function() {
return this.firstName + ' ' + this.surname;
}
});
alert(user.fullName); // Вася Петров