동일한 기능을 하지만
유지보수에 용이한 리팩토링
function fullstack(backend, frontend) {
this.backend = backend;
this.frontend = frontend;
fullstack.prototype.getBackend = () => this.backend;
fullstack.prototype.setBackend = () => (this.backend = backend);
fullstack.prototype.getFrontend = () => this.frontend;
fullstack.prototype.setFrontend = () => (this.frontend = frontend);
}
const Fullstack = new fullstack('javascript', 'javascript');
console.log(Fullstack.getBackend());
console.log(Fullstack.getFrontend());
class fullStack {
constructor(backend, frontend) {
//async 사용불가
this.backend = backend;
this.frontend = frontend;
}
getBackend() {
return this.backend;
}
getFrontend() {
return this.frontend;
}
setBackend(backend) {
this.backend = backend;
}
setFrontend(frontend) {
this.frontend = frontend;
}
}
const FullStack = new fullStack('javascript', 'javascript');
console.log(FullStack.getBackend());
console.log(FullStack.getFrontend());
'JavaScript > javascript 기초 공부하기' 카테고리의 다른 글
javascript - requestAnimationFrame (0) | 2020.12.06 |
---|---|
javascript 객체지향을 위한 class 생성하기 (0) | 2020.05.02 |
커링 함수 currying function (0) | 2020.05.02 |
every, some, Set, startsWith, includes, endsWidth (0) | 2020.05.02 |
async / await (0) | 2020.01.26 |