toString.js 580 B

1234567891011121314151617181920212223242526272829
  1. var baseToString = require('./_baseToString');
  2. /**
  3. * Converts `value` to a string. An empty string is returned for `null`
  4. * and `undefined` values. The sign of `-0` is preserved.
  5. *
  6. * @static
  7. * @memberOf _
  8. * @since 4.0.0
  9. * @category Lang
  10. * @param {*} value The value to convert.
  11. * @returns {string} Returns the converted string.
  12. * @example
  13. *
  14. * _.toString(null);
  15. * // => ''
  16. *
  17. * _.toString(-0);
  18. * // => '-0'
  19. *
  20. * _.toString([1, 2, 3]);
  21. * // => '1,2,3'
  22. */
  23. function toString(value) {
  24. return value == null ? '' : baseToString(value);
  25. }
  26. module.exports = toString;