Is there a way to use JS to check if a text file exist?

I am not sure what is the keyword that should be used to check for e.g

(file.txt).exists();

Something like this. I am sure that my syntax have problem. But the main idea is to check if a txt exists before i start reading.

Thanks in advance.

Have a look in the Mono docs under System.IO. The File class has a method called Exists that does what you want.