> For the complete documentation index, see [llms.txt](https://lodash.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lodash.shujuwajue.com/function/once.md).

# \_.once

**语法：**

```javascript
_.once(func)
```

**源代码链接：**[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L10616)

**npm包链接：**[npm package](https://www.npmjs.com/package/lodash.once)

**描述：**

创建一个只能调用`func`一次的函数。 重复调用返回第一次调用的结果。`func`调用时，`this`绑定到创建的函数，并传入对应参数

**开始版本：**&#x30;.1.0

**参数：**

* `func (Function)`: 指定的触发的函数。

**返回值：**

* `(Function)`: 返回新的受限函数。

**例子：**

```javascript
var initialize = _.once(createApplication);
initialize();
initialize();
// `initialize` 只能调用 `createApplication` 一次。
```
