WARNING: The [sjs-3] engine was deprecated, use [sjs-4] instead.

File.prototype.parent()

Return a file’s parent.

Syntax

file.parent() File file.parent() null

Parameters

cross bool (default false)

Cross filesystem boundaries. Getting the parent of an imported filesystem’s root file returns null, unless crossing is enabled, in which case it returns the parent on the importing filesystem. With crossing enabled, you will always get what you would expect by path.

Description

Return a file’s direct ancestor. If no parent is accessible, eg. for the root file, null is returned.

Examples

Example when parent exists.

Example when no parent exists.

Cross filesystem boundaries. Note that in this playground, we can not import remote filesystems, thus we can not show the difference here of using the cross argument.