Path

path.is-absolute()

Tests whether the path syntax is absolute under the selected path implementation. Tested on Node.js 22.16.0. An absolute path may still be invalid or outside the intended directory.

Formal Syntax & Structure

nodejs syntaxnodejs
path.isAbsolute(path)

Parameters & Attributes

NameTypeDescription
pathstringPath text.

Return Value

boolean

Whether the syntax is absolute.

Working Example

Example Snippetnodejs
import path from 'node:path';console.log(JSON.stringify([path.posix.isAbsolute('../book'),path.win32.isAbsolute('C:\\books')]));
Node.js Reference