Javascript/vanilla
-
ES6 문법Javascript/vanilla 2024. 2. 28. 20:54
ES5와 달라진 ES6 문법 📌 기본 파라미터와 가변 파라미터 - 기본 파라미터 function addContact( name, mobile, home = "없음", address = "없음", email = "없음" ) { let str = `name = ${name}, mobile = ${mobile}, home = ${home}, address = ${address}, email = ${email}`; console.log(str); } addContact("홍길동", "010-1234-5678") // name = 홍길동, mobile = 010-1234-5678, home = 없음, address = 없음, email = 없음 addContact("이몽룡", "010-1234-5678", "03..
-
var, let, const 변수와 호이스팅Javascript/vanilla 2024. 2. 28. 20:36
var, let, const 변수란 ? 호이스팅이란 ? 📌 var 변수 - ES6(ECMAScript6) 등장 이전 주로 사용하던 변수 - 호이스팅(Hoisting)에 의한 Javascript 이해 난이도 상승 📌 호이스팅(Hoisting) - " 변수의 선언을 스코프(범위) 최상단으로 옮기는 행위 " - 코드의 실행을 호이스팅 단계 -> 실행 단계 로 구분 // 호이스팅 단계 1. JS 코드를 파싱(구문 분석) 2. var 키워드로 선언된 변수의 메모리 할당(변수 미리 선언) 3. Javascript 에서는 변수만 선언되면 undefined로 초기화 // 실행 단계 1. 호이스팅 단계에서 메모리가 할당되면 코드 실행 // 예제 console.log(A1); var A1 = "hello"; -> 결과 :..
-
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 ..