Lodash - trimStart 方法



語法

_.trimStart([string=''], [chars=whitespace])

從字串中移除前導空白或指定的字元。

引數

  • [string=''] (string) − 要修剪的字串。

  • [chars=whitespace] (string) − 要修剪的字元。

輸出

  • (string) − 返回修剪後的字串。

示例

var _ = require('lodash');
var result = _.trimStart('__abc__', '_');

console.log(result);

將上述程式儲存在 tester.js 中。執行以下命令來執行該程式。

命令

\>node tester.js

輸出

abc__
lodash_string.htm
廣告
© . All rights reserved.