- 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 - spilt method
Syntax
_.split([string=''], separator, [limit])
Splits string by separator.
Arguments
[string=''] (string) − The string to split.
separator (RegExp|string) − The separator pattern to split by.
[limit] (number) − The length to truncate results to.
Output
(Array) − Returns the string segments.
Example
var _ = require('lodash'); var result = _.split('a-b-c', '-'); console.log(result); result = _.split('a-b-c', '-', 2); console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
[ 'a', 'b', 'c' ] [ 'a', 'b' ]
lodash_string.htm
Advertisements