What is the method for reading and writing a file in JavaScript?

What is the method for reading and writing a file in JavaScript?

You can read or write to files in only server-side JavaScript i.e. NodeJS by using the fs module where fs = File System. Read more about fs module here.

Whereas you cannot do the same on browser due to security restrictions.