본문 바로가기
728x90
반응형

JavaScript186

스택(Stacks) References 아래 링크의 강의 중 Section 19. Stack 'Em Up With Stacks의 내용을 추려 이번 글을 작성하였습니다. The Coding Interview Bootcamp: Algorithms + Data Structures on Udemy Solution class Stack { constructor() { this.data = []; } push(record) { this.data.push(record); } pop() { return this.data.pop(); } peek() { return this.data[this.data.length - 1]; } } // const s = new Stack(); // s.push(1); // s.push(2); // .. 2022. 4. 5.
큐 합치기(Queue Weaving) References 아래 링크의 강의 중 Section 18. Underwater Queue Weaving의 내용을 추려 이번 글을 작성하였습니다. The Coding Interview Bootcamp: Algorithms + Data Structures on Udemy Solution // ./queue.js class Queue { constructor() { this.data = []; } add(record) { this.data.unshift(record); } remove() { return this.data.pop(); } peek() { return this.data[this.data.length - 1]; } } module.exports = Queue; // ./index.js cons.. 2022. 4. 5.
큐(The Queue) References 아래 링크의 강의 중 Section 17. The Queue의 내용을 추려 이번 글을 작성하였습니다. The Coding Interview Bootcamp: Algorithms + Data Structures on Udemy Solution class Queue { constructor() { this.data = []; } add(record) { this.data.unshift(record); } remove() { return this.data.pop(); } } Queue란? 선입선출(FIFO) 방식으로 작동하는 일련의 데이터 모음이다. 아래 그림을 보면 알 수 있듯 새로이 선언한 q에 add method로써 1과 2를 추가하면 1 뒤에 2가 추가된다. 여기서 q.remove(.. 2022. 4. 5.
피보나치의 수열(Fibonacci Sequence) References 아래 링크의 강의 중 Section 16. Runtime Complexity in Practice - Fibonacci의 내용을 추려 이번 글을 작성하였습니다. The Coding Interview Bootcamp: Algorithms + Data Structures on Udemy Solution 1. for loop function fib(n) { const result = [0, 1]; for (let i = 2; i 2022. 4. 5.
초심자를 위한 함수의 정의와 arguments_3. arguments & parameters from Secrets of the JavaScript Ninja 이번 글은 'Secrets of the JavaScript Ninja'의 'Chapter 3. First-class functions for the novice: definitions and arguments'를 바탕으로 작성하였습니다. 핵심 Concepts 함수를 이해하는 것이 중요한 이유 함수는 어떻게 first-class objects일까? 함수를 정의하는 방법들 파라미터는 어떻게 부여되는가 사전 지식 체크! callbak funtion은 어떤 환경에서 쓰이는가? 동기적인 환경? 아니면 비동기적인 환경? arrow function과 function expression의 차이점? 왜 default parameter를 사용하는가? Arguments and function parameters 우리는 흔히.. 2022. 4. 5.
초심자를 위한 함수의 정의와 arguments_2. 함수 정의 방법 from Secrets of the JavaScript Ninja 이번 글은 'Secrets of the JavaScript Ninja'의 'Chapter 3. First-class functions for the novice: definitions and arguments'를 바탕으로 작성하였습니다. 핵심 Concepts 함수를 이해하는 것이 중요한 이유 함수는 어떻게 first-class objects일까? 함수를 정의하는 방법들 파라미터는 어떻게 부여되는가 사전 지식 체크! callbak funtion은 어떤 환경에서 쓰이는가? 동기적인 환경? 아니면 비동기적인 환경? arrow function과 function expression의 차이점? 왜 default parameter를 사용하는가? Defining functions JavaScript의 function는.. 2022. 4. 5.
나선형 매트릭스(Spiral Matrix) References 아래 링크의 강의 중 Section 14. Enter the Matrix Spiral의 내용을 추려 이번 글을 작성하였습니다. The Coding Interview Bootcamp: Algorithms + Data Structures on Udemy Solution function matrix(n) { // 1. Create empty array of arrays called 'results' const results = []; for (let i = 0; i < n; ++i) { results.push([]); } // 2. Create variables let cnt = 1; let startCol = 0; let endCol = n - 1; let startRow = 0; let.. 2022. 4. 5.
초심자를 위한 함수의 정의와 arguments_1. 객체로서의 함수 from Secrets of the JavaScript Ninja 이번 글은 'Secrets of the JavaScript Ninja'의 'Chapter 3. First-class functions for the novice: definitions and arguments'를 바탕으로 작성하였습니다. 핵심 Concepts 함수를 이해하는 것이 중요한 이유 함수는 어떻게 first-class objects일까? 함수를 정의하는 방법들 파라미터는 어떻게 부여되는가 사전 지식 체크! callbak funtion은 어떤 환경에서 쓰이는가? 동기적인 환경? 아니면 비동기적인 환경? arrow function과 function expression의 차이점? 왜 default parameter를 사용하는가? 들어가며 JavaScript를 통달하기 위해서는 JavaScript가 f.. 2022. 4. 5.
웹 애플리케이션의 생애주기(the lifecycle of a web application)_2. event-handling from Secrets of the JavaScript Ninja 이번 글은 'Secrets of the JavaScript Ninja'의 'Chapter 2. Building the page at runtime'을 바탕으로 작성하였습니다. 핵심 Keywords 웹 애플리케이션 생애주기의 단계 웹 페이지를 만들기 위한 HTML code의 절차 JavaScript code의 실행 순서 이벤트를 활용하여 interactive한 page 만들기 event loop 사전 지식 체크! 브라우저는 HTML code가 짜인 대로 page를 생성하는가? 웹 애플리케이션은 한 번에 event를 몇 개 처리하는가? 브라우저가 event를 처리하기 위해 event queue를 쓰는 이유? 2. event-handling page-building 단계가 끝나고 나면 event-handlin.. 2022. 4. 4.
728x90
반응형