Lodash - join method



Syntax

_.join(array, [separator=','])

Converts all elements in array into a string separated by separator.

Arguments

  • array (Array) − The array to convert.

  • [separator=','] (string) − The element separator.

Output

  • (string) − Returns the joined string.

Example

var _ = require('lodash');
var list = [1, 2, 3, 4, 5, 6];

var result = _.join(list,'~')
console.log(result);

Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

Output

1~2~3~4~5~6
lodash_array.htm
Advertisements