> For the complete documentation index, see [llms.txt](https://ddzy.gitbook.io/ts-utility-plugins-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ddzy.gitbook.io/ts-utility-plugins-docs/utility/utility-array/tostrictarray.md).

# toStrictArray

### 说明

&#x20;将给定的类数组转化为严格的数组(`非原地`)

### 源码

<https://github.com/ddzy/ts-utility-plugins/tree/master/src/ddzy/utility/array/toStrictArray>

### 用法

{% code title="toStrictArray.test.ts" %}

```typescript
import { toStrictArray } from "../../utility/array/toStrictArray";

describe('toStrictArray', () => {
  test('toStrictArray should receive an `ArrayLike` and return the `Array`', () => {
    document.body.innerHTML += `
      <div></div>
      <div></div>
    `;
    const received1 = { length: 0 };
    const received2 = {
      0: 'ddzy',
      1: 20,
      length: 2,
    };
    const received3 = document.querySelectorAll('div');
    const received4 = [1, 2, 3, 4];

    const result1 = toStrictArray(received1);
    const result2 = toStrictArray(received2);
    const result3 = toStrictArray(received3);
    const result4 = toStrictArray(received4);

    expect(result1.length).toBe(0);
    expect(result2.length).toBe(2);
    expect(result3.length).toBe(2);
    expect(result4.length).toBe(4);

    expect(result2[0]).toBe(received2[0]);
    expect(result3[0]).toBe(received3[0]);
    expect(result4[0]).toBe(received4[0]);
  });
});
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ddzy.gitbook.io/ts-utility-plugins-docs/utility/utility-array/tostrictarray.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
