# getParamNames

### 说明

&#x20;获取函数的`形参`名称数组

### 源码

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

### 用法

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

```typescript
import { getParamNames } from "../../utility/function/getParamNames";

describe('getParamNames', () => {
  test("getParamsNames should receive lots of parameters and return the array of each parameter's name.", () => {
    const received = [
      function (..._args: any[]) { },
      function func1(_name: string, _age: number) { },
      function func2(_name: string, _age: number, _address: string, ..._args: any[]) { },
    ];
    const expected = [
      [],
      ['_name', '_age'],
      ['_name', '_age', '_address'],
    ];

    for (const [i, v] of received.entries()) {
      const current = getParamNames(v);
      expect(current).toEqual(expected[i]);
    }
  });
});
```

{% endcode %}


---

# Agent Instructions: 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:

```
GET https://ddzy.gitbook.io/ts-utility-plugins-docs/utility/utility-function/getparamnames.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
