Super - ๋ถ๋ชจ ํด๋์ค - super ํค์๋๋ constructor ์์์๋ ํจ์์์๋ง ์ฌ์ฉํ ์ ์๋ค. class Person { name; year; constructor(name, year) { this.name = name; this.year = year; } sayHello() { return `Hello I'm ${this.name}`; } } class Singer extends Person { sing() { return `๋
ธ๋ํฉ๋๋ค.`; } constructor(name, year, part) { // ๋ถ๋ชจ ํด๋์ค // Person() ์ด๊ฑฐ๋ ๋๊ฐ์ super(name, year); this.part = part; } sayHello() { // undefined์
๋๋ค. rap ํํธ์
..
๐ง TIL/๐ค JS, TS
์์, Inheritance - ์์์ ๊ฐ์ฒด๋ค ๊ฐ์ ๊ด๊ณ๋ฅผ ๊ตฌ์ถํ๋ ๋ฐฉ๋ฒ์ด๋ค. - ์ํผ ํด๋์ค(๋๋ ๋ถ๋ชจ ํด๋์ค)๋ฑ์ ๊ธฐ์กด์ ํด๋์ค๋ก๋ถํฐ ์์ฑ๊ณผ ๋์์ ์์๋ฐ์ ์ ์๋ค. - ๊ณตํต๋๋ ๋ฐ์ดํฐ๋ฅผ ์ ๋ฆฌํ ์ ์๋ ๋ฐฉ๋ฒ์ด๋ค. class Person { name; year; constructor(name, year) { this.name = name; this.year = year; } } class Singer extends Person { sing() { return `๋
ธ๋ํฉ๋๋ค.`; } } class Actor extends Person { acting() { return `์ฐ๊ธฐํฉ๋๋ค.`; } } const zico = new Singer("zico", 1993); console.log(zico); // ..
Static - ๊ฐ์ฒด์ ๊ท์๋์ง ์๋๋ค. - ํด๋์ค์ ์ง์ ๊ท์๋ผ์ new๋ก ์ธ ํ์ ์๋ค. class Person { name; year; static groupName = '์ค'; constructor(name, year) { this.name = name; this.year = year; } // ํจ์๋ ๊ฐ๋ฅ static returnGroupName() { return '์ค'; } } const soo = new Person('soo', 1997); // ๊ฐ์ฒด์ ๊ท์๋์ง ์๋๋ค. console.log(soo);// Person { name: 'soo', year: 1997 } // ๊ทธ๋ผ ์ด๋์ ๊ท์๋ผ์๋? // ํด๋์ค ์์ฒด์ ๊ท์๋์ด์๋ค! console.log(Person.groupName)// ์ค..
Getter 1. ๋ฐ์ดํฐ๋ฅผ ๊ฐ๊ณตํด์ ์๋ก์ด ๋ฐ์ดํฐ๋ฅผ ๋ฐํํ ๋ 2. privateํ ๊ฐ์ ๋ฐํํ ๋ Setter 1. ๊ฐ์ ์ค์ ํด์ค๋ ๋ฌผ๋ก Setter ์์ด๋ ๋ฐ๊ฟ ์๋ ์์ง๋ง ํ๋กํผํฐ๋ฅผ private์ผ๋ก ๋ฐ๊ฟจ์๋๋ Setter์์ด ๋ฐ๊ฟ ์ ์๋ค. private์ ์ง์ ์ก์ธ์ค๊ฐ ๋ถ๊ฐ 2. Setter๋ ์ ์ํ ๊ฐ์ ๋ณ๊ฒฝํ๋ ๊ฒ์ด๊ธฐ ๋๋ฌธ์ ๋ง์ด ์ ํธํ์ง๋ ์์ class Person { name; year; constructor(name, year) { this.name = name; this.year = year; } // Getter, Setter get getNameAndYear() { return `${this.name}-${this.year}`; } // ๋ฐ๊พธ๊ณ ์ถ์ ํ๋กํผํฐ์ ์ด๋ฆ๊ณผ ๊ฒน์น๊ฒ ๋ง์ด ์ค..
ํด๋์ค? - ๊ฐ์ฒด์งํฅ ํ๋ก๊ทธ๋๋ฐ์์ ํน์ ๊ฐ์ฒด(์ธ์คํด์ค)๋ฅผ ์์ฑํ๊ธฐ ์ํ ๋ณ์์ ๋ฉ์๋(ํจ์)๋ฅผ ์ ์ํ๋ ์ผ์ข
์ ํ์ด๋ค. - ์ ๋ณด๋ฅผ ์ผ๋ฐํํด์ ์ ๋ฆฌํ๋ ๋ฐฉ๋ฒ์ด๋ค! class person { // ์ด๋ค ํ๋กํผํฐ๊ฐ ์กด์ฌํ๋์ง ๋ฏธ๋ฆฌ ์ ์ํ๋ ๊ฒ์ ์์ฃผ ์ข์ ์ต๊ด! name; year; // ์์ฑ์ constructor(name, year) { this.name = name; this.year = year; } // ํด๋์ค ๋ด ๋ฉ์๋ ์ ์ // ์๋ฌต์ ์ผ๋ก ํจ์๋ผ๋๊ฑธ ์ธ์งํจ sayName() { return `์๋
ํ์ธ์ ์ ๋ ${this.name}์
๋๋ค.` } }
const soo1 = { name: 'sooyoung', age: 27 } const soo2 = { name: '์์', ...soo1, } const soo3 = { ...soo1, name: '์์', } console.log(soo2);// { name: 'sooyoung', age: 27 } console.log(soo3);// { name: '์์', age: 27 } - soo2๋ name: '์์'์ ๋จผ์ ์ ์ธ ํ์ผ๋ ์ ๊ฐ ์ฐ์ฐ์๋ฅผ ๊ทธ ๋ค์์ ํผ์ณ์คฌ์ผ๋ฏ๋ก '์์'์ผ๋ก name ๊ฐ์ด ๋ฐ๋์ง ์๋๋ค. - ์๋๋๋ก ๋ฐ๊ฟ์ฃผ๋ ค๋ฉด ์ ๊ฐ ์ฐ์ฐ์๋ฅผ ๋จผ์ ํผ์น๊ณ ๋์ ๋ฐ๊ฟ์ฃผ๋ ์์๋ก ์งํํด์ผ ํ๋ค.
Copy of Value - ๊ฐ์ ์ํ ์ ๋ฌ Copy of Reference - ์ฐธ์กฐ์ ์ํ ์ ๋ฌ - ๊ธฐ๋ณธ์ ์ผ๋ก ๋ชจ๋ primitive ๊ฐ์ ๊ฐ์ ์ํ ์ ๋ฌ์ด๋ค.(function, object, array ๋นผ๊ณ ๋๋จธ์ง) - ๊ฐ์ฒด๋ ์ฐธ์กฐ์ ์ํ ์ ๋ฌ์ด๋ค const soo1 = { name: 'sooyoung', age: 27 } const soo2 = soo1; const soo3 = { name: 'sooyoung', age: 27 } const soo4 = { ...soo3, } console.log(soo1 === soo2);// true console.log(soo1 === soo3);// false console.log(soo2 === soo3);// false console.log(soo3 ==..

๋ณธ๊ฒฉ์ ์ธ node.js ์ฃผ์ฐจ๊ฐ ์์๋๋ค. ์๋ฐ์คํฌ๋ฆฝํธ ๊ฝค ์ต์ํด์ง ์ค ์์๋๋ฐ ์์ง ์จ๋ณด์ง ๋ชปํ๋ ๊ตฌ์กฐ ๋ถํด ํ ๋น์ด ํท๊ฐ๋ ค ๊ธฐ๋กํด๋ด์ผ๊ฒ ๋ค. ๐งจ ๊ตฌ์กฐ ๋ถํด ํ ๋น - ๋ฐฐ์ด์ด๋ ๊ฐ์ฒด์ ์์ฑ์ ํด์ฒดํ์ฌ ๊ทธ ์์ ๊ฐ์ ๊ฐ๋ณ ๋ณ์๋ก ๋ด์ ์ ์๊ฒ ํ๋ ํํ์ - ๊ตฌ์กฐํ๋ ๋ฐฐ์ด๊ณผ ๊ฐ์ ์ดํฐ๋ฌ๋ธ ๋๋ ๊ฐ์ฒด๋ฅผ ๊ตฌ์กฐํ๊ดด(destructuring) ํ์ฌ 1๊ฐ ์ด์์ ๋ณ์์ ๊ฐ๋ณ์ ์ผ๋ก ํ ๋นํ๋ ๊ฒ์ ๋งํ๋ค. - ๋ฐฐ์ด์ ๊ฐ ์์๋ฅผ ๋ฐฐ์ด๋ก๋ถํฐ ์ถ์ถ, 1๊ฐ ์ด์์ ๋ณ์์ ํ ๋นํ๋ค.(๋ฐฐ์ด์ ๊ธธ์ด์ ๋ง์ถฐ์ ๋ณ์ ํ ๋น ํ์ง ์์๋ OK) - ๋ฐฐ์ด ๊ตฌ์กฐ ๋ถํด ํ ๋น์ ๋์(ํ ๋น๋ฌธ์ ์ฐ๋ณ)์ ์ดํฐ๋ฌ๋ธ์ด์ด์ผ ํ๋ค. ๐โ๏ธ ์ดํฐ๋ฌ๋ธ? Symbol.iterator๋ฅผ ํ๋กํผํฐ ํค๋ก ์ฌ์ฉํ ๋ฉ์๋๋ฅผ ์ง์ ๊ตฌํํ๊ฑฐ๋ ํ๋กํ ํ์
์ฒด์ธ ํตํด ์์ ๋ฐ์..

๋ฉ์๋๋ ์์ ์ด ์ํ ๊ฐ์ฒด์ ์ํ, ์ฆ ํ๋กํผํฐ๋ฅผ ์ฐธ์กฐํ๊ณ ๋ณ๊ฒฝํ ์ ์์ด์ผ ํ๋ค. ์ด๋ ๋ฉ์๋๊ฐ ์์ ์ด ์ํ ๊ฐ์ฒด์ ํ๋กํผํฐ๋ฅผ ์ฐธ์กฐํ๋ ค๋ฉด ๋จผ์ ์์ ์ด ์ํ ๊ฐ์ฒด๋ฅผ ๊ฐ๋ฆฌํค๋ ์๋ณ์๋ฅผ ์ฐธ์กฐํ ์ ์์ด์ผ ํ๋ค. 1. this? - ์์ ์ด ์ํ ๊ฐ์ฒด ๋๋ ์์ ์ด ์์ฑํ ์ธ์คํด์ค๋ฅผ ๊ฐ๋ฆฌํค๋ ์๊ธฐ ์ฐธ์กฐ ๋ณ์(self-referencing variable) - this๋ฅผ ํตํด ์์ ์ด ์ํ ๊ฐ์ฒด ๋๋ ์์ ์ด ์์ฑํ ์ธ์คํด์ค์ ํ๋กํผํฐ๋ ๋ฉ์๋๋ฅผ ์ฐธ์กฐํ ์ ์๋ค. - ๋จ, this๊ฐ ๊ฐ๋ฆฌํค๋ ๊ฐ, ์ฆ this ๋ฐ์ธ๋ฉ์ ํจ์ ํธ์ถ ๋ฐฉ์์ ์ํด ๋์ ์ผ๋ก ๊ฒฐ์ ๋๋ค. - ํด๋์ค ๊ธฐ๋ฐ ์ธ์ด์์ this๋ ์ธ์ ๋ ํด๋์ค๊ฐ ์์ฑํ๋ ์ธ์คํด์ค๋ฅผ ๊ฐ๋ฆฌํค๋๋ฐ , ์๋ฐ์คํฌ๋ฆฝํธ์ this๋ ํจ์๊ฐ ํธ์ถ๋๋ ๋ฐฉ์์ ๋ฐ๋ผ this์ ๋ฐ์ธ๋ฉ๋ ..

๋ถํธ์คํธ๋ฉ์ผ๋ก ๋ชจ๋ฌ์ฐฝ ๋์ด๋ณด์! 1. ๋ถํธ์คํธ๋ฉ CDN์ผ๋ก ๋ถ๋ฌ์ค๊ธฐ ๐โ๏ธ cdn์ด๋? - Content Delivery Network - ๋ฌผ๋ฆฌ์ ์ผ๋ก ๋จ์ด์ ธ ์๋ ์ฌ์ฉ์์๊ฒ ์ปจํ
์ธ ๋ฅผ ๋ ๋น ๋ฅด๊ฒ ์ ๊ณตํ๊ธฐ ์ํด ๊ณ ์๋ ๊ธฐ์ ์ด๋ค. - ๋ง์ฝ ์ฐ๋ฆฌ๋๋ผ์ ์๋ ์ฌ๋์ด ๋ฏธ๊ตญ์ ์๋ ์๋ฒ๋ก๋ถํฐ ์ด๋ฏธ์ง๋ ํ์ผ ๋ฑ์ ๋ค์ด๋ฐ์ผ๋ ค๊ณ ํ๋ค๋ฉด ์๊ฐ์ด ์ค๋ ๊ฑธ๋ฆด ๊ฒ, " ๋ฐ๋ผ์ ์๋ฒ๋ฅผ ๋ถ์ฐ์์ผ ์บ์ฑํด๋๊ณ ์ฌ์ฉ์์ ์ปจํ
์ธ ์์ฒญ์ด ๋ค์ด์ค๋ฉด ์ฌ์ฉ์์ ๊ฐ์ฅ ๊ฐ๊น์ด ์์น์ ์กด์ฌํ๋ ์๋ฒ๋ก ๋งคํ์์ผ ์์ฒญ๋ ์ฝํ
์ธ ์ ์บ์ฑ๋ ๋ด์ฉ์ ๋ด์ด์ฃผ๋ ๋ฐฉ์์ผ๋ก ๋น ๋ฅด๊ฒ ๋ฐ์ดํฐ๋ฅผ ์ ์กํ ์ ์๊ฒ ๋๋ค. " - ๋ง์ฝ ์๋ฒ๊ฐ ํ์ผ์ ์ฐพ๋๋ฐ ์คํจํ๋ ๊ฒฝ์ฐ CDN ํ๋ซํผ์ ๋ค๋ฅธ ์๋ฒ์์ ์ปจํ
์ธ ๋ฅผ ์ฐพ์๋ค์ ์๋ต์ ์ ์กํ๋ค. ์ฐธ๊ณ ์๋ฃ: https://velog.io/..