전체 글
-
Spread 연산자 & 구조분해할당 & 참조형 타입Javascript/vanilla 2022. 4. 3. 09:24
Spread 연산자(...) 란 ? 구조분해할당이란 ? 📌 Spread 연산자 const fruits = [ 'apple', 'banana', 'watermelon' ] const newFruits = [ ...fruits, 'mango' ] // newFruits = [ 'apple', 'banana', 'watermelon', 'mango' ] - ... 을 사용하여 해당 변수의 데이터를 복사한다. const fnc = (...args) => args const arr = fnc(1, 2, 3) // arr = [ 1, 2, 3 ] - 함수의 parameter로 spread 연산자를 사용하면 입력된 매개변수들이 배열로 합쳐진다. 📌 구조분해할당 const fruits = [ 'apple', 'bana..
-
Export & ImportJavascript/vanilla 2022. 4. 2. 21:17
차세대 Javascript의 모듈식 코드 작성법 Export & Import 📌Javascript module 가져오기 // person.js const person = { name: 'Max' } export default person - default 구문을 사용하여 person 객체를 기본 내보내기 - 기본 내보내기(default)는 어떤 이름으로도 Import 해올 수 있다. // utility.js export const clean = () => {...} export const baseData = 10 - 각각에 export를 달아 각 모듈을 이름 내보내기 - 정의한 이름으로 Import 해올 수 있다. // app.js import person from './person.js' import ..
-
Typescript로 프로젝트 시작하기(1/n) - 프로젝트 생성Javascript/react 2022. 3. 15. 16:28
React + Typescript를 사용하여 프로젝트를 만들어보자. 1. 명령 프롬포트(cmd)를 사용해도 되고, 사용하는 개발 툴의 터미널을 사용해도 됨. npx create-react-app my-app --template typescript my-app : 프로젝트 명. 원하는 이름으로 수정 node version >= 14 (nvm 사용 권장) 2. 시작 npm start http://localhost:3000 으로 실행 3. 폴더 구조 my-app/ node_modules public/ favicon.ico index.html logo192.png logo512.png manifest.json robots.txt src/ App.css App.test.tsx App.tsx index.css in..