프론트엔드(3)
-
프로미스(Promise)와 async/await란?
HTML 삽입 미리보기할 수 없는 소스 **자바스크립트의 비동기 처리란 “특정 로직의 실행이 끝날 때까지 기다려주지 않고, 나머지 코드를 먼저 실행하는 것”을 의미합니다. (즉, 아래 #2번에서 실행이 끝날 때까지 안 기다려주고, 바로 #3번을 먼저 실행하는 것) ex) 자바스크립트에서 비동기 처리가 필요한 이유를 생각해보면, 화면에서 서버로 데이터를 요청했을 때, 서버가 언제 그 요청에 대한 응답을 줄지도 모르는데 마냥 다른 코드를 실행 안 하고 기다릴 순 없기 때문입니다. Promise Promise란 비동기 작업이 종료된 후에, 실행이 잘 성공했는지 혹은 실패했는지 성공 또는 실패의 결과값이 무엇인지 위 세가지 내용을 미래(비동기 작업이 종료된 후)에 반환해주겠다고 약속해주는 객체이다. (A pro..
2023.05.09 -
프로토타입 객체(The Prototype Object)
HTML 삽입 미리보기할 수 없는 소스 The prototype object is simply an object that multiple other objects can refer to to get any information or functionality that they need. For our needs, each of our constructor functions will have a prototype that all their instances will be able to refer to. 프로토타입 객체는 필요한 정보나 기능을 얻기 위해 다른 여러 객체가 참조할 수 있는 객체입니다. 필요에 따라 각 생성자 함수에는 모든 인스턴스가 참조할 수 있는 프로토타입이 있습니다. So let's clar..
2023.05.09 -
생성자 함수와 this 키워드(Constructor Functions and keyword "this")
HTML 삽입 미리보기할 수 없는 소스 function User(firstName, lastName, age, gender) { this.firstName = firstName; this.lastName = lastName; this.age = age; this.gender = gender; } const user1 = new User('Jill', 'Smith', 33, 'female'); const user2 = new User('Bob', 'Smith', 24, 'male'); user1 and user2 are objects of the class User. user1과 user2는 User 클래스의 객체입니다. You might be wondering how all these properties..
2023.05.09