castArray
最后更新于:2022-04-02 00:01:40
## castArray
+ [link](./castArray "Link to this entry.")
+ [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L9262 "View in source.")
+ [npm](https://www.npmjs.com/package/lodash.castarray "See the npm package.")
```
_.castArray(value)
```
如果 `value` 不是数组, 那么强制转为数组
### 参数
1. value (\*)
要处理的值
### 返回值 (Array)
返回转换后的数组
### 示例
```
_.castArray(1);
// => [1]
_.castArray({ 'a': 1 });
// => [{ 'a': 1 }]
_.castArray('abc');
// => ['abc']
_.castArray(null);
// => [null]
_.castArray(undefined);
// => [undefined]
_.castArray();
// => []
var array = [1, 2, 3];
console.log(_.castArray(array) === array);
// => true
```
';