node-fs-writefile Flashcards
1
Q
What method is available in the Node.js fs module for writing data to a file?
A
writeFile method.
ex:
const data = new Uint8Array(Buffer.from(‘Hello Node.js’));
fs.writeFile(‘message.txt’, data, (err) => {
if (err) throw err;
console.log(‘The file has been saved!’);
});
2
Q
Are file operations using the fs module synchronous or asynchronous?
A
asynchronous, because comparing to other programs they run very slow.