-
[항해99 WIL] ES5 VS ES6네트워크/CS Study 2023. 6. 21. 14:08
왜 알아야하는가?
모든 회사가 최신 문법을 항상 사용한다는 생각이라면 굳이 안해도 된다. 하지만 일말의 가능성도 있으니 레거시를 분석할 때 이해를 못하면 좀 쪽팔릴것이다 그래서 알아야한다.
ES5는 2009년에 ES6 2015년에 출시된 것으로 뒤에 숫자는 각각의 버전을 의미하고 있다
뭐가 바뀌었냐?
1. ES5
- strict mode (엄격 모드)의 도입 : 코드 자성의 실수나 잠재적인 오류를 방지하기 위한 규칙 도입
- 배열 메소드 추가: forEach, map, filter, reduce 메소드
- JSON객체
- bind 메소드 등
2. ES6
- let과 const의 도입: 블럭 범위 변수 선언 지원
- 화살표 함수('=>') : 더 간결한 함수 표현식을 작성할 수 있게 되었다. 이 화살표 함수는 함수 컨텍스트 내에서 this를 자동으로 바인딩 한다. 그리고 function 키워드보다 짧은 문법으로 함수를 정의할 수 있다.
- 클래스: 프로토 타입 기반 상속을 간결하게 작성할 수 있는 클래스 문법을 도입했다. class 키워드로 클래스를 정의하고, constructor 메소드로 객체 초기화를 수행할 수 있다.
- 템플릿 리터럴: 백틱으로 감싸진 문자열을 작성할 수 있고 여러 줄에 걸쳐 문자열을 작성할 수 있다.
- destructuring 할당: 배열이나 객체의 속성을 추출하여 변수에 바로 할당할 수 있는 문법이다.
- Promise 객체: 비동기 작업의 성공 또는 실패를 처리하기 위한 표준화된 방법을 제공한다.
- Generator 함수: 'function'키워를 사용하여 제너레이터 함수를 정의할 수 있다. 제너레이터는 실행을 중지하고 재개할 수 있는 함수로, 비동기 코드 작성을 간소화하는데 유리하다.
ES2020, 2021 등의 버전들도 새로운 기능을 꾸준히 도입하고 있고 자바스크립트의 입지 또한 넓어지고 있다.
참조
https://hbsowo58.tistory.com/407
https://nayoungkim00.tistory.com/51
'네트워크 > CS Study' 카테고리의 다른 글
[CS Study] TypeScript를 사용해야하는 이유 (0) 2023.06.27 [항해99 WIL] Virtual DOM && props && state (0) 2023.06.26 [CS Study] Closure (0) 2023.06.21 [CS Study] MVVM && FLUX (0) 2023.06.20 [CS Study] 스코프란 & 호이스팅이란 무엇일까??? (1) 2023.06.19