PhantomJS - isAbsolute



This method returns true if the filepath is absolute. If the filepath is relative, it returns false.

Syntax

Its syntax is as follows −

var fs = require('fs'); 
fs.isAbsolute(path);

Example

The following example shows the use of isAbsolute() method.

var fs = require('fs'); 
var path ='C:\phantomjs\bin\a.txt';
if (fs.isAbsolute(path)) { 
   console.log(' Absolute path.'); 
} else { 
   console.log('NOT an absolute path.'); 
} 
phantom.exit(); 

The above program generates the following output.

Absolute path.
phantomjs_file_system_module_methods.htm
Advertisements