class User {
constructor(first, last) {
this.firstName = first
this.lastName = last
}
getFullName() {
return `${this.firstName} ${this.lastName}`
}
}
const ju = new User('Ju', 'Oh');
const lisa = new User('Lisa', 'Oh');
console.log(ju.getFullName());
console.log(lisa.getFullName());
class User {
constructor(first, last) {
this.firstName = first
this.lastName = last
this.fullName = `${first} ${last}`
}
}
const lisa = new User('Lisa', 'Oh');
console.log(lisa);
lisa.firstName = 'Ju';
console.log(lisa);
class User {
constructor(first, last) {
this.firstName = first
this.lastName = last
}
getFullName() {
return `${this.firstName} ${this.lastName}`
}
}
const lisa = new User('Lisa', 'Oh');
console.log(lisa.getFullName());
lisa.firstName = 'Ju';
console.log(lisa.getFullName());
class User {
constructor(first, last) {
this.firstName = first
this.lastName = last
}
get fullName() {
return `${this.firstName} ${this.lastName}`
}
set fullName(value) {
console.log(value);
[this.firstName, this.lastName] = value.split(' ');
}
}
const lisa = new User('Lisa', 'Oh');
console.log(lisa.fullName);
lisa.firstName = 'Ju';
console.log(lisa.fullName);
lisa.fullName = 'Ju Park'
console.log(lisa);