I'm learning a bit of NodeJS
. The last thing I learned was to read a file.
The question that left me with doubt is the following. When I use the readFile
function with the second parameter being utf8
, the reading of the file occurs as expected (the same way it happens in PHP, where I come from).
Example:
var fs = require('fs')
fs.readFile('files/text.txt', 'utf8', function (err, data) {
console.log(data)
});
However, when I do not pass the argument indicating that the reading will be like utf8
, things change:
fs.readFile('files/text.txt', function (err, data)
{
console.log(data)
});
Output:
<Buffer 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 20 61 64 69 70 69 73 69 63 69 6e 67 ...>
What is the meaning of this <Buffer>
?