JavaScript
-
[Javascript] 비동기 프로그래밍(promise, async/await)JavaScript 2024. 7. 11. 10:18
promise, async/await으로 비동기를 처리하는 예제를 통해 자바스크립트가 비동기를 처리하는 과정을 살펴보겠습니다.const findUserById = (userId) => { console.log('findUserById 함수 호출'); return new Promise((resolve, reject) => { console.log('findUserById 함수가 반환하는 promise 객체'); if (userId === 1) { resolve('유저를 찾았습니다.'); } else { reject(new Error(`userId가 ${userId}인 유저를 찾을 수 없습니다.`)); } });};async function getUser() { ..
-
1장 데이터 타입JavaScript 2023. 3. 27. 03:04
💡‘코어 자바스크립트’ 책을 보며 정리한 글입니다. 1. 데이터 타입의 종류기본형(primitive type)Number, String, Boolean, null, undefined, Symbol값이 담긴 주솟값 복제불변값참조형(reference type)Array, Function, Date, RegExp, Map, WeakMap, Set, WeakSet값이 담긴 주솟값들로 이루어진 묶음을 가리키는 주솟값 복제가변값 2. 데이터 타입에 관한 배경지식2.1 메모리와 데이터자바스크립트는 상대적으로 메모리 관리에 대한 압박에서 자유로움숫자의 경우 8바이트를 확보모든 데이터는 메모리 주솟값을 통해 서로 구분하고 연결할 수 있다. 2.2 식별자와 변수변수 : 변할 수 있는 수식별자 : 변수명, 어떤 데이터를 식..