node read file sync
// load fs
const fs = require("fs");
// read the file
const content = fs.readFileSync("./my_file.txt");
// print it
console.log(content.toString());fs.readFile('filename', function read(err, data) {
if (err) {
throw err;
}
var content = data;
console.log(content);
});// macOS, Linux, and Windows
fs.readFileSync('<directory>');
// => [Error: EISDIR: illegal operation on a directory, read <directory>]
// FreeBSD
fs.readFileSync('<directory>'); // => <data>
Also in JavaScript:
- javascript mouse drag coordinates
- jquery get mouse page left and top
- user account in react
- save data in local storage reactjs returns [object, object]
- how to make popup modal in jquery with example
- javascript convert number to spreadsheet column
- how to make an if statement in javascript
- how to initialize events in fullcalendar through json data in laravel
- javascript picture delete after time
- object methods in javascript
- cypress
- javascript hash string
- jQuery - Get Content and Attributes
- check radio button is checked jquery
- nodejs get file size
- button click javascript by class
- chart.js npm install
- best js ide
- express js example
- javascript array get nth element
- javascript snumber two decimal places as string
- nested array loop in javascript
- multiple ternary operator javascript
- print all variables defined javascript