← 문제 목록
초급 Node.js 30P

Node.js 비동기 처리 이해하기

Node.js에서는 비동기 프로그래밍을 사용하여 IO 작업을 처리합니다. 아래 코드는 파일 시스템 모듈을 사용하여 파일을 읽고 그 결과를 출력하는 함수를 정의합니다.



위 코드에서 `fs.readFile` 메소드는 어떤 방식으로 파일을 읽어오고 결과를 처리하나요?
JAVASCRIPT
const fs = require('fs');

function readFileExample() {
    fs.readFile('example.txt', 'utf8', (err, data) => {
        if (err) {
            console.error(err);
            return;
        }
        console.log(data);
    });
}

답변

로그인 후 제출하기
0명 풀이 · 정답률 0%