join.js 693 B

123456789101112131415161718192021222324252627
  1. /** Used for built-in method references. */
  2. var arrayProto = Array.prototype;
  3. /* Built-in method references for those with the same name as other `lodash` methods. */
  4. var nativeJoin = arrayProto.join;
  5. /**
  6. * Converts all elements in `array` into a string separated by `separator`.
  7. *
  8. * @static
  9. * @memberOf _
  10. * @since 4.0.0
  11. * @category Array
  12. * @param {Array} array The array to convert.
  13. * @param {string} [separator=','] The element separator.
  14. * @returns {string} Returns the joined string.
  15. * @example
  16. *
  17. * _.join(['a', 'b', 'c'], '~');
  18. * // => 'a~b~c'
  19. */
  20. function join(array, separator) {
  21. return array == null ? '' : nativeJoin.call(array, separator);
  22. }
  23. module.exports = join;