📎아이템 58 모던 자바스크립트로 작성하기
🔗 ECMAScript 모듈 사용하기
🔗 프로토타입 대신 클래스 사용하기
// 프로토타입 기반 객체
function Person(first, last) {
this.first = first;
this.last = last;
}
Person.prototype.getName = function() {
return this.first + ' ' + this.last;
}
const marie = new Person('Marie', 'Curie');
console.log(marie.getName());// 클래스 기반 객체
class Person {
constructor(first, last) {
this.first = first;
this.last = last;
}
getName() {
return this.first + ' ' + this.last;
}
}
const marie = new Person('Marie', 'Curie');
console.log(marie.getName());🔗 var 대신 let/const 사용하기
🔗 for(;;) 대신 for-of 또는 배열 메서드 사용하기
🔗 함수 표현식보다 화살표 함수 사용하기
🔗 단축 객체 표현과 구조 분해 할당 사용하기
🔗 함수 매개변수 기본값 사용하기
🔗 저수준 프로미스나 콜백 대신 async/await 사용하기
🔗 연관 배열에 객체 대신 Map과 Set 사용하기
🔗 타입스크립트에 use strict 넣지 않기
📍 요약
Last updated