πŸ’ŽΒ  JS기본상식 (ES6의 νŠΉμ§•)

νš¨λ”©λ”©Β·2022λ…„ 8μ›” 22일
0

ES6 λž€ 무엇인가?

  • μš°μ„  ESλž€ ECMAScript의 μ•½μžλ‘œ μžλ°”μŠ€ν¬λ¦½νŠΈμ˜ ν‘œμ€€, κ·œκ²©μ„ λ‚˜νƒ€λ‚΄λŠ” μš©μ–΄μž„
  • ES λ’€μ˜ μˆ«μžλŠ” 버전을 λœ»ν•˜λŠ” κ²ƒμœΌλ‘œ ES6은 버전 6을 μ˜λ―Έν•˜λ©°, 2015년에 μΆœμ‹œλ˜μ—ˆκ³  ν‘œμ€€μ— λ§Žμ€ λ³€ν™”κ°€ μžˆμ—ˆμŒ

λŒ€ν‘œμ μœΌλ‘œ μ•„λž˜ λͺ‡κ°€μ§€λ‘œ μš”μ•½ν•΄λ΄„:

1. let, const

  • κΈ°μ‘΄μ—λŠ” varλ₯Ό ν†΅ν•΄μ„œ λ³€μˆ˜λ₯Ό μ„ μ–Έν•˜κ³  ν• λ‹Ήν–ˆμ§€λ§Œ, ES6λΆ€ν„°λŠ” letκ³Ό constκ°€ 지원됨.
  • let은 μž¬μ„ μ–Έ λΆˆκ°€, μž¬ν• λ‹Ή κ°€λŠ₯ν•œ λ³€μˆ˜μ΄κ³  constλŠ” μž¬μ„ μ–Έ λΆˆκ°€, μž¬ν• λ‹Ή λΆˆκ°€λŠ₯ν•œ λ³€μˆ˜μž„.

2. ν…œν”Œλ¦Ώ λ¦¬ν„°λŸ΄

  • λ°±ν‹±(Back tick)을 지원.
  • 기쑴에 μžλ°”μŠ€ν¬λ¦½νŠΈ λ³€μˆ˜λ₯Ό λ¬Έμžμ—΄κ³Ό ν•¨κ»˜ μ“°κΈ°μœ„ν•΄μ„œλŠ” +λ₯Ό ν†΅ν•΄μ„œ μ—°κ²°ν•΄μ£Όμ–΄μ•Ό ν–ˆμ§€λ§Œ, ν…œν”Œλ¦Ώ λ¦¬ν„°λŸ΄μ΄ μ§€μ›λ˜λ©° ν•œλ²ˆμ— λ‚˜νƒ€λ‚Ό 수 있게 λ˜μ—ˆμŒ.
  • μ‚¬μš©λ°©λ²•μ€ λ‚˜νƒ€λ‚΄κ³ μž ν•˜λŠ” λ¬Έμžμ—΄μ„ λ°±ν‹±μœΌλ‘œ 감싸고, 쀑간에 μžλ°”μŠ€ν¬λ¦½νŠΈ ν‘œν˜„μ‹μ„ μ‚¬μš©ν•˜κ³  μ‹Άλ‹€λ©΄ ν•΄λ‹Ή λ³€μˆ˜λ₯Ό ${} 둜 λ¬Άμ–΄ ν‘œν˜„μ΄ κ°€λŠ₯함.

3. 객체 λ¦¬ν„°λŸ΄

  • 객체 μ•ˆμ— ν•¨μˆ˜λ₯Ό μ‚¬μš©ν•˜λŠ” 것이 κ°€λŠ₯ν•΄μ‘ŒμŒ.
  • 이전보닀 간결해진 μ½”λ“œλ‘œ 객체λ₯Ό μ„ μ–Έν•˜λŠ” 것이 κ°€λŠ₯ν•΄μ‘ŒμŒ.

4. ν™”μ‚΄ν‘œ ν•¨μˆ˜

  • ν•¨μˆ˜ν‘œν˜„μ‹μ„ ν™”μ‚΄ν‘œ ν•¨μˆ˜λ‘œ κ°„κ²°ν•˜κ²Œ ν‘œν˜„ κ°€λŠ₯ν•΄μ‘ŒμŒ.
  • ν™”μ‚΄ν‘œ ν•¨μˆ˜λ₯Ό 톡해 λ§Œλ“€μ–΄μ§„ 본문에 return 만 μžˆλŠ” 경우 returnκ³Ό {}λ₯Ό μƒλž΅ν•  수 있음.

5. ꡬ쑰 λΆ„ν•΄ ν• λ‹Ή

  • 말 κ·ΈλŒ€λ‘œ ꡬ쑰λ₯Ό λΆ„ν•΄ν•΄μ„œ ν• λ‹Ήν•˜κ² λ‹€λŠ” 뜻으둜 κ°μ²΄λ‚˜ λ°°μ—΄μ—μ„œ μ‚¬μš©λ¨.
  • 값을 ν•΄μ²΄ν•˜κ³ , 각각 κ°œλ³„ 값을 λ³€μˆ˜μ— μƒˆλ‘œ ν• λ‹Ήν•˜λŠ” 과정을 μ˜λ―Έν•¨.

6. Promise

  • μ΄μ „μ—λŠ” 비동기λ₯Ό μ²˜λ¦¬ν•˜κΈ° μœ„ν•΄μ„œ callback ν•¨μˆ˜λ₯Ό μ΄μš©ν•œ μ½œλ°±νŒ¨ν„΄μ„ ν†΅ν•˜μ˜€λŠ”λ° μ½œλ°±ν—¬μ„ λ°œμƒμ‹œν‚€λŠ” λ¬Έμ œκ°€ μžˆμ—ˆμŒ.
  • 이λ₯Ό ν•΄κ²°ν•˜κΈ° μœ„ν•΄ ν”„λ‘œλ―ΈμŠ€κ°€ λ„μž…λ˜μ—ˆκ³ , ν”„λ‘œλ―ΈμŠ€ ν›„μ†μ²˜λ¦¬ λ©”μ†Œλ“œλ₯Ό μ΄μš©ν•΄μ„œ μ—λŸ¬ 처리λ₯Ό 효과적으둜 ν•  수 있게 λ˜μ—ˆμŒ.

7. Class

  • μžλ°”μŠ€ν¬λ¦½νŠΈλŠ” ν”„λ‘œν† νƒ€μž… 기반의 객체지ν–₯μ–Έμ–΄λ‘œ 클래슀 기반의 객체 지ν–₯ ν”„λ‘œκ·Έλž˜λ°μ„ μ§€μ›ν•˜λ„λ‘ Class ν‚€μ›Œλ“œλ₯Ό λ„μž…ν•˜μ˜€μŒ.
  • Class의 λ„μž…μœΌλ‘œ 상속 λ“±μ˜ κ°œλ…μ„ μ μš©ν•  수 μžˆμ–΄ 더 쒋은 가독성을 가진 μ½”λ“œλ₯Ό λ§Œλ“€μ–΄ λ‚Ό 수 있게됨.

8. String ν•¨μˆ˜

  • includes, startsWith, endsWith ν•¨μˆ˜κ°€ μƒˆλ‘œ 좔가됨.

9. Multi-line String

  • λ¬Έμžμ—΄μ΄ 라인을 λ„˜μ–΄κ°€κ²Œ 되면 κ°œν–‰λΆ€ν˜Έμ™€ λ§μ…ˆμ„ ν†΅ν•΄μ„œ μ‚¬μš©ν•΄μ•Όν–ˆμ§€λ§Œ, 백틱이 μ§€μ›λ˜λ©° μ—¬λŸ¬ 쀄 문자의 관리가 νŽΈν•΄μ‘ŒμŒ.

10. Module

  • λͺ¨λ“ˆμ΄λž€ μž¬μ‚¬μš©μ„ μœ„ν•œ μ½”λ“œ 쑰각으둜 μžμ„Έν•œ 사항은 μΊ‘μŠν™”λ₯Ό ν†΅ν•΄μ„œ 감좔고, APIλΆ€λΆ„λ§Œ 외뢀에 λ…ΈμΆœν•˜μ—¬ μ½”λ“œμ˜ μž¬μ‚¬μš©μ„±μ„ μ¦κ°€μ‹œμΌ°μŒ.

좜처:
https://velog.io/@quin1392/ES6%EC%9D%98-%ED%8A%B9%EC%A7%95
https://fz7948.tistory.com/56


(영문 해석)

  • ECMAScript 6, also known as ECMAScript 2015, is the latest version of the ECMAScript standard. ES6 is a significant update to the language, and the first update to the language since ES5 was standardized in 2009.

ES6 includes the following new features:

-arrows
-classes
-enhanced object literals
-template strings
-destructuring
-default + rest + spread
-let + const
-iterators + for..of
-generators
-unicode
-modules
-module loaders
-map + set + weakmap + weakset
-proxies
-symbols
-subclassable built-ins
-promises
-math + number + string + array + object APIs
-binary and octal literals
-reflect api
-tail calls

Source:
https://github.com/lukehoban/es6features

profile
μ–΄μ œλ³΄λ‹€ λ‚˜μ€ λ‚˜μ˜ 코딩지식

0개의 λŒ“κΈ€