> For the complete documentation index, see [llms.txt](https://docs.angular-package.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.angular-package.dev/sass/list/list.nth.md).

# list.nth()

The `list.nth()` function returns the element of [`$list`](#usdlist) at index [`$n`](#usdn) and/or with elements of given indexes [`$nts...`](#usdnts...).

{% hint style="info" %}
Function modify original by adding [`$nts...`](#usdnts...) arbitrary parameter at the end.
{% endhint %}

{% code lineNumbers="true" %}

```scss
// Sass.
@use 'sass:list';

// The `list.nth()` function.
@function nth($list, $n, $nts...) {
  $result: ();
  @each $n in list.join($n, $nts, comma) {
    @if $n and $n != 0 {
      $result: list.append(
        $result,
        if(
          list.length($list) >= if($n < 0, calc($n * -1), $n),
          list.nth($list, $n),
          null
        ),
        list.separator($list)
      );
    }
  }
  @return if(list.length($nts) > 0, $result, list.nth($result, 1));
}
```

{% endcode %}

{% embed url="<https://github.com/angular-package/sass/blob/main/list/_list.nth.function.scss>" %}

### Parameters

#### **`$list`**&#x20;

A list from which the element of index [`$n`](#usdn) and/or multiple indexes `$nts` are retrieved.

#### `$n`

The required index of [`$list`](#usdlist).

#### `$nts...`

Optional multiple indexes of [`$list`](#usdlist).

### Return

The return value is a retrieved element or list of retrieved elements.

## Examples

```scss
// Use.
@use 'angular-package/sass/list';

// Examples.
// single `$n`
@debug list.nth(('a', 'b', 'c', 'd', 'e', 'f'), 4); // d

// multiple `$nts...`
@debug list.nth(('a', 'b', 'c', 'd', 'e', 'f'), 4, 3, 4); // "d", "c", "d"

// null or false
@debug list.nth(('a', 'b', 'c', 'd', 'e', 'f'), 10); // null
@debug list.nth(('a', 'b', 'c', 'd', 'e', 'f'), 10) or false; // false
@debug list.nth(('a', 'b', 'c', 'd', 'e', 'f'), -10); // null
@debug list.nth(('a', 'b', 'c', 'd', 'e', 'f'), -10) or false; // false

```
