본문 바로가기

Front End42

[JS] Avoid callback hell, Promise udemy, The Complete JavaScript Course 2021: From Zero to Expert! / Teacher: Jonas Schmedtmann Promise chain을 사용하는 목적은 Callback HELL에서 벗어나기 위함이다. Promise : An object that is used as a placeholder for the future result of an asynchronous operation. 'AJAX call과 같은 미래에 받을 값을 담아놓는 상자' 정도로 이해하면 될 거 같다. setTimeout(() => { console.log('1 second passed'); setTimeout(() => { console.log('2 seconds passed'.. 2021. 6. 20.
[JS] Object-Oriented Programming (OOP) Object-Oriented Programming (OOP) was developed with the goal of organizing code, to make it more flexible and easier to maintain (avoid 'spagetti code') - 최근에 SW 엔지니어링에서 가장 많이 쓰임. 죽 늘여놓는 코드를 쓰지 않고 정리할 수 있도록 해주며 유지보수를 쉽게 할 수 있다. [3 Ways of implementing prototypical inheritance in Javascript] 1) Constructor function 2) ES6 Classes : 쓰이는 코드의 방식이 constructor function과 매우 흡사하다. 3) Object.create() Th.. 2021. 6. 16.
[JS] Constructor Function : Prototype chain 졸면서 강의 듣다가 이해하지 못한 상태에서 Coding Challenge를 하려고 하니 문제를 어떻게 풀어야할지 모르겠어서 정신 차리고 다시 집중해서 강의를 들었다. Constructor Function을 이용하는 이유는, 같은 코드를 똑같이 반복해서 쓰지 않고 같은 속성의 object를 만들기 위함이다. const Person = function(firstName, birthYear) { this.firstName = firstName; this.birthYear = birthYear; }; Person.prototype.calcAge = function() { console.log(2037 - `${this.birthYear}`) }; const Student = function(firstName, .. 2021. 6. 15.
[JS] ES6 Classes // class expression // const PersonCl = class {} // class declaration class PersonCl = { constructor(firstName, birthYear) { this.firstName = firstName; this.birthYear = birthYear; } // Method will be added to .prototype property calcAge() { console.log(2037 - this.birthYear) } greet() { console.log(`Hello ${this.firstName}`) } } const fuse = PersonCl('Fuse', 1994) console.log(fuse) // PersonCl .. 2021. 6. 14.
[JS] The Complete JavaScript Course 2021: From Zero to Expert! | # 165 Test Data const dogs = [ { weight: 22, curFood: 250, owners: ['Alice', 'Bob'] }, { weight: 8, curFood: 200, owners: ['Matilda'] }, { weight: 13, curFood: 275, owners: ['Sarah', 'John'] }, { weight: 32, curFood: 340, owners: ['Michael'] }, ]; Your tasks: 1. Loop over the 'dogs' array containing dog objects, and for each dog, calculate the recommended food portion and add it to the object as a new.. 2021. 6. 8.