Lodash教程

Lodash spilt method

语法

_.split([string=''], separator, [limit])
Splits string by separator.

参数

[string=''] (string) − The string to split. separator (RegExp|string) − The separator pattern to split by. [limit] (number) − The length to truncate results to.

输出

(Array) − Returns the string segments.

实例

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

输出

[ 'a', 'b', 'c' ]
[ 'a', 'b' ]
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4