Lodash - toString 方法

语法

_.toString(value)

将值转换为字符串。对于 null 和未定义的值,将返回空字符串。保留 -0 的符号。

参数

  • value (*) − 要转换的值。

输出

  • (string) − 返回转换后的字符串。

示例

var _ = require('lodash');
 
console.log(_.toString(-0));
console.log(_.toString([1, 2, 3]));

将上述程序保存在tester.js中。运行以下命令执行该程序。

命令

\>node tester.js

输出

-0
1,2,3

lodash_lang.html