---
title: "joinPath"
description: "Serialize an array of path segments into a single path string, the inverse of toPath for building dot and bracket accessors."
canonical_url: "https://core.mhaibaraai.cn/en/docs/helpers/path/join-path"
---
# joinPath

> Serialize an array of path segments into a single path string, the inverse of toPath for building dot and bracket accessors.

## Usage

`joinPath` serializes an array of path segments into a path string.

```ts
import { joinPath } from '@movk/core'

const p = joinPath(['a', 'x.y', 0, 'space key'])
// p: "a['x.y'][0]['space key']"
// Round-trips with toPath: toPath(p) => ['a', 'x.y', 0, 'space key']
```

## API

### `joinPath(segments)`

Serialize an array of path segments into a path string.

### Parameters

**segments** (`[string | number]()`) *required*: An array of path segments.

### Returns

**returns** (`string`): The serialized path string.

## Changelog

See commit history for [src/helpers/path/joinPath.ts](https://github.com/mhaibaraai/movk-core/commits/main/src/helpers/path/joinPath.ts).

---

- [GitHub](https://github.com/mhaibaraai/movk-core/blob/main/src/helpers/path/joinPath.ts)


## Sitemap

See the full [sitemap](https://core.mhaibaraai.cn/sitemap.md) for all pages.
