
๐ Drag & Drop 2๏ธโฃ Tuple is an array tuple์ JavaScript์๋ ์๊ณ TypeScript์๋ง ์๋ ํ์ ์ด๋ค. ๋ฐ๋ผ์ ํน์ ๋ณ์๋ฅผ tuple ํ์ ์ผ๋ก ์ง์ ํ์ ๋, ์๋์ ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก tuple ํ์ ์์ ํ์ธํ ์ ์๋ค. const engineer: [string, string, string] = ['Apeach', 'Ogu', 'Choonsik']; engineer instanceof Tuple; // โ typeof engineer === 'tuple'; // โ (false) But tuple์ TypeScript์๋ง ์กด์ฌํ๋ ํ์ ์ด์ง๋ง JavaScript๋ก ์๊ฐํด๋ดค์ ๋ ๊ฒฐ๊ตญ์ ๋ฐฐ์ด์ด๋ค. ๊ทธ๋ฌ๋ฏ๋ก ์ ์ธํ ๋ณ์๊ฐ tuple์ด ๋ง๋์ง ํ์ธํ๋ ค๋ฉด ๋ฐฐ์ด์ธ์ง ์ฌ๋ถ๋ฅผ ํ์ธ..

Decorators 3๏ธโฃ Validation decorator ํ๋กํผํฐ ๋ฐ์ฝ๋ ์ดํฐ ์์ class Course { title: string; price: number; constructor(t: string, p: number) { this.title = t; this.price = p; } } const courseForm = document.querySelector('form')!; courseForm.addEventListener('submit', event => { event.preventDefault(); const titleEl = document.getElementById('title') as HTMLInputElement; const priceEl = document.getElementB..

Decorators 2๏ธโฃ Decorator the synthetic sugar ํด๋์ค ๋ฐ์ฝ๋ ์ดํฐ๋ constructor๋ฅผ ๋ฐํํ๋ฉด์ ๊ธฐ์กด constructor๋ฅผ ํ์ฅํ ์ ์๋ค. constructor๋ฅผ ํ์ฅํ ๋ super();๋ ๊ธฐ์กด ํด๋์ค ํ์ฅ์์์ ๋ง์ฐฌ๊ฐ์ง๋ก ๊ธฐ์กด ํด๋์ค์ ์ ๋ณด๋ฅผ ๊ธฐ์ตํ๊ณ ์ถ์ ๋ ์ฌ์ฉํ๋ฉด ๋๋ค. function ClassDeco() { return function(target: T) { return class extends target { constructor(..._: any[]) { super(); // not necessary /* write your code */ } } } } @ClassDeco class Person { name = 'Shou'; get name() {..

Decorators 1๏ธโฃ What is Decorators? ํด๋์ค, ํ๋กํผํฐ, ์ก์ธ์, ๋ฉ์๋, ํ๋ผ๋ฏธํฐ์ ์ฒจ๋ถํ ์ ์๋ ํน๋ณํ ํจ์์ด๋ค. ๋ฐ์ฝ๋ ์ดํฐ๊ฐ ๋ถ์ ํด๋์ค ๋ฑ๋ฑ ์์๋ ๋ฐ์ฝ๋ ์ดํฐ์์ ์ ์๋ ๊ธฐ๋ฅ์ด ๋์ํ๋ค. ์ ์ํ ๋ฐ์ฝ๋ ์ดํฐ ํจ์๋ฅผ @ ๊ธฐํธ๋ฅผ ๋ถ์ฌ ์คํํ ์ ์๋ค. function ClassDeco(constructor: Function) { console.log('Logging...'); console.log(constructor); } @ClassDeco class Person { name = 'Shou'; constructor() { console.log('Creating person object...'); } } /* Logging... class Person { constructo..