The _.join()
method in Lodash converts all the values of an array into a string separated by the specified separator.
_.join(array, separator)
This method accepts the following parameters:
array
: This is the array to be converted into a string.separator
: This is the separator. Its default value is a comma (,
).This method returns a string of all the array values separated by the specified separator.
In the "HTML" tab:
lodash
script.In the "JavaScript" tab:
info
array and populate it with a few values.separator
and initialize it with _
._.join()
method to convert all the values of an array into a string.result
to the console. In the output, we see a string that contains all the values of the array separated by _
.