Lodash - trimEnd 方法
語法
_.trimEnd([string=''], [chars=whitespace])
從字串中移除尾隨空白或指定字元。
引數
[string=''] (字串) − 要修剪的字串。
[chars=whitespace] (字串) − 要修剪的字元。
輸出
(字串) − 返回修剪後的字串。
示例
var _ = require('lodash');
var result = _.trimEnd('__abc__', '_');
console.log(result);
將上述程式儲存在 tester.js 中。執行以下命令來執行此程式。
命令
\>node tester.js
輸出
__abc
lodash_string.htm
廣告