---
name: "up.Layer.prototype.ancestors"
area: "API"
kind: "Property"
parent: "up.Layer class"
url: "https://unpoly.com/api/up.Layer.prototype.ancestors"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.Layer class](https://unpoly.com/api/up.Layer.md)</nav>

# up.Layer.prototype.ancestors

Returns an array of this layer's ancestor layers.

The array elements are ordered by distance to this layer. The first element is this layer's direct parent. The last element is the [root layer](https://unpoly.com/api/up.layer.root.md).

## Example {#example}

```js
// Open two overlays
up.layer.open({ mode: 'drawer' })
up.layer.open({ mode: 'modal' })

up.layer.current.ancestors // returns [up.Layer.Drawer, up.Layer.Root]
```

---

## Return value {#return-value}

ancestors This layer's ancestors.

Type: [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[up.Layer](https://unpoly.com/api/up.Layer.md)>

