- Lodash Tutorial
- Lodash - Home
- Lodash - Overview
- Lodash - Environment Setup
- Lodash - Array
- Lodash - Collection
- Lodash - Date
- Lodash - Function
- Lodash - Lang
- Lodash - Math
- Lodash - Number
- Lodash - Object
- Lodash - Seq
- Lodash - String
- Lodash - Util
- Lodash - Properties
- Lodash - Methods
- Lodash Useful Resources
- Lodash - Quick Guide
- Lodash - Useful Resources
- Lodash - Discussion
Lodash - castArray method
Syntax
_.castArray(value)
Casts value as an array if it's not one.
Arguments
value (*) − The value to inspect.
Output
(Array) − Returns the cast array.
Example
var _ = require('lodash'); console.log(_.castArray(1)); console.log(_.castArray({ 'a': 1 }));
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
[ 1 ] [ { a: 1 } ]
lodash_lang.htm
Advertisements