목록분류 전체보기 (294)
Muscardinus
class Graph { constructor() { this.numberOfNodes = 0; this.adjacentList = { }; } addVertex(node) { if (!this.adjacentList[node]) { this.adjacentList[node] = []; this.numberOfNodes++; } } addEdge(node1, node2) { //undirected Graph if (!(this.adjacentList[node1] && this.adjacentList[node2])) return null; this.adjacentList[node1].push(node2); this.adjacentList[node2].push(node1); } showConnections(..
이진탐색트리 시뮬레이션 연습 사이트 visualgo.net/en/bst class Node { constructor(value){ this.left = null; this.right = null; this.value = value; } } class BinarySearchTree { constructor(){ this.root = null; } insert(value){ const newNode = new Node(value); if (!this.root) this.root = newNode; else { let currentNode = this.root; while(1) { if (value < currentNode.value) { if (!currentNode.left) { currentNode.le..
Linked List Method class Node { constructor(value) { this.value = value; this.next = null; } } class Queue { constructor() { this.first = null; this.last = null; this.length = 0; } peek() { return this.fist; } enqueue(value) { const newNode = new Node(value); if (!this.length) { this.first = this.last = newNode; } else { this.last.next = newNode; this.last = newNode; } this.length++; return this..
Linked List Method class Node { constructor(value) { this.value = value; this.next = null; } } class Stack { constructor() { this.top = null; this.bottom = null; this.length = 0; } peek() { return this.top; } push(value) { const newNode = new Node(value); if (!this.length) { this.top = newNode; this.bottom = newNode; } else { this.top.next = newNode; this.top = newNode; } this.length++; return t..

JS Engine은 많은 일을 한다. 하지만 그 중에서 가장 핵심적인 2가지 역할을 해준다! 그것은 바로 Reading과 Executing이다. Reading 정보(변수, 함수 등)를 특정한 장소에 저장 Executing 현재 실행되고 있는 코드를 추적하는 작업 여기서 정보를 저장하는 공간이 바로 Memory Heap이고, 실행 중인 코드를 추적하는 공간이 Call Stack이다. Memory Heap Memory Heap은 수 많은 서랍을 가지고 있는 하나의 큰 서랍장이라고 생각하면 된다. 내가 놓고 싶은 물건을 서랍에 넣어두었다가 필요할 때 마다 꺼내쓰기 위한 서랍장이라고 생각해두자. 각각의 서랍에 우리는 변수 및 함수를 저장하는 서랍장이 Memory heap이다. // tell the memory ..
What is JS Engine? muscardinus.tistory.com/171 저번 시간에 우리는 JS Engine의 구동원리에 대해서 배웠다. 그리고 마무리하면서 더 빠르고 최적화된 JS Engine의 작동을 돕기 위해서 우리 자신 또한 Optimized Code를 작성해야한다고 하였다. 그렇다면 그 방법에는 어떠한 것이 있을까? 우선 해당 항목들의 사용을 자제하는 것을 추천한다. - eval() - arguments -> arguments를 직접으로 사용하는 것을 피하고, arguments.length와 arguments[i]의 형식으로 사용하자 - for in문 -> 차라리 Object.key()를 사용하자 - with - delete 자 그러면 이제 시작해보자! Inline Caching f..

우리는 웹개발을 하면서 HTML, CSS, 그리고 자바스크립트를 작성한다. 하지만 우리가 작성한 파일들을 컴퓨터에서 어떻게 알고 웹페이지상으로 보이게 하는지 고민한 적은 잘 없을 것이다. 이번 글은 그 원리를 설명하기 위해서 작성하게 되었다. JavaScript Engine 자바스크립트 엔진은 JS 코드를 컴퓨터가 이해하고 실행할 수 있는 언어(Machine Language)로 변형하는 작업을 해주는 Engine이다. 그 종류는 매우 많다. 그리고 그 많은 종류의 엔진들은 ECMA Script에 표준을 두어서 개발을 한다. 그 중 가장 대표적으로 사용하는 엔진이 Chrome Broswer에서 제공하는 V8 Engine이다. ※ 해당 글은 V8 Engine을 기준으로 작성하겠습니다. List Of Java..

지금까지 this의 1,2,3탄을 읽었다면 이 자리를 빌려서 무한한 감사를 표합니다. 제가 조금이나마 도움이 되었다면 그것만으로도 보람찰것 같습니다! 자 그러면 이제 this의 마지막인 new에 관하여 이야기해보자! new 아직 실력이 부족하여 설명을 정확히 하기에는 부족한 감이 있어 예제로 대체하겠습니다 new 키워드를 사용한 함수 내부에서의 this가 가르키는 것은 새로운 빈 객체이다. 그리고 이것(this)을 new 키워드를 통하여 부여한다. 이거 하나만 기억하자! 출력값 위 코드를 보면 알듯이 type 인자에 "muscardinus"를 주면, 하나의 새로운 animal 인스턴스가 생기고 그것의 this는 this.type으로 "muscardinus"를 보유하고 있다. new 키워드와 함께 사용될 ..