๋ฐ์ํ
[์ถ์ฒ-Youtube ์ํ์ฝ๋ฉ]
https://www.youtube.com/watch?v=7woGFlMhSgk&list=PLuHgQVnccGMA9QQX5wqj6ThK7t2tsGxjm&index=37
syntax/sample.txt
B
syntax/sync.js
var fs = require('fs');
/*
//readFileSync
console.log('A');
var result = fs.readFileSync('syntax/sample.txt', 'utf8');
console.log(result);
console.log('C');
*/
console.log('A');
fs.readFile('syntax/sample.txt', 'utf8', function(err, result){ // ํจ์๋ฅผ 3๋ฒ์งธ ์ธ์๋ก ์ค
console.log(result);
});
console.log('C');
readFileSync์ return๊ฐ์ ์ฃผ๊ณ
readFile๋ ๋ฆฌํด ๊ฐ์ด ์์ (๋์ ํจ์๋ฅผ 3๋ฒ์งธ ์ธ์๋ก ์ค์ผ ํจ)
๋ฐ์ํ
'JavaScript > Node.js' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Node.js-์ํ์ฝ๋ฉ] ํจํค์ง ๋งค๋์ ์ PM2 (0) | 2021.02.06 |
---|---|
[Node.js-์ํ์ฝ๋ฉ] JavaScript - callback (0) | 2021.01.29 |
[Node.js-์ํ์ฝ๋ฉ] ๋๊ธฐ์ ๋น๋๊ธฐ (0) | 2021.01.29 |
[Node.js-์ํ์ฝ๋ฉ] App ์ ์ - ํจ์๋ฅผ ์ด์ฉํด์ ์ ๋ฆฌ ์ ๋ํ๊ธฐ (0) | 2021.01.28 |
[Node.js-์ํ์ฝ๋ฉ] JavaScript - ํจ์์ ์ถ๋ ฅ (0) | 2021.01.28 |
๋๊ธ