9. Promise (state, producer, consumer)
두 가지 고려 1. state(상태) : process가 operation을 수행하고 있는 중인지, 기능 수행이 완료된 후 성공했는지 실패했는지 2. producer, consumer의 차이점 (원하는 데이터를 제공하는 사람과, 제공된 데이터를 필요로 하는 사람에 대한 이해) ->Promise를 이용하여 callback 지옥 극복할 수 있다 - state (pending, fulfilled, rejected) pending (operation 수행 중)-> fulfilled(완료된 상태) or rejected(문제 발생) console.log("Promise 시작!!"); // 1.Producer // 2.Consumer : then, catch, finally // then (성공했을 때, resolv..
7-1. 배열실습 (array-api 이용)
// Q1. make a string out of an array { const fruits = ['apple', 'banana', 'orange']; } // Q2. make an array out of a string { const fruits = '🍎, 🥝, 🍌, 🍒'; } // Q3. make this array look like this: [5, 4, 3, 2, 1] { const array = [1, 2, 3, 4, 5]; } // Q4. make new array without the first two elements { const array = [1, 2, 3, 4, 5]; } class Student { constructor(name, age, enrolled, score) { this...
7. 배열 Array
Array, Map, Set, List 어떤 자료구조 알고리즘을 사용하면 삽입, 검색, 정렬, 삭제에 효율적인지 (BigO) 배열 (index : 0부터 시작) 1. 배열 선언 - new Array(); - [값,값,값] 2. 배열 index 접근 const fruits=['사과','바나나']; console.log(fruits); console.log(fruits.length); //2 console.log(fruits[1]); 3. for of, 4. forEach 바로 콜백함수를 받아온다 5. Addition, Deletion (push, pop, unshift, shift, splice, concat) 뒤에 추가 push(값) 뒤에서 빼는 것 pop() 앞에 값 추가 unshift(값) 앞에 값 ..