Lodash - toString 方法



語法

_.toString(value)

將值轉換為字串。對於 null 和 undefined 值,將返回空字串。會保留 -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.htm
廣告
© . All rights reserved.