1.

How will you open a file using Node?

Answer»

Following is the syntax of the method to open a file in asynchronous mode:

fs.open(path, flags[, mode], callback)

Parameters

Here is the description of the parameters used:

  • path − This is string having file name including path.

  • flags − Flag tells the behavior of the file to be opened. All possible values have been mentioned below.

  • mode − This sets the file mode (permission and sticky bits), but only if the file was created. It defaults to 0666, readable and writeable.

  • callback − This is the callback function which gets two arguments (err, fd).



Discussion

No Comment Found