> 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/lang/tosafeinteger.md).

# \_.toSafeInteger（强转为安全整数）

**语法：**

```javascript
_.toSafeInteger(value)
```

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

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

**描述：**

转换`value`为安全整数。 安全整数可以用于比较和准确的表示。

**开始版本：**&#x34;.0.0

**参数：**

* `value (*)`: 要转换的值。

**返回值：**

* `(number)`: 返回转换后的整数。

**例子：**

```javascript
_.toSafeInteger(3.2);
// => 3

_.toSafeInteger(Number.MIN_VALUE);
// => 0

_.toSafeInteger(Infinity);
// => 9007199254740991

_.toSafeInteger('3.2');
// => 3
```
