移除字符串末尾指定的字符。
需要修剪的原始字符串,可以为 null。
一个包含需要移除字符的字符串,默认为空格。这些字符将被视为一个集合,任何在末尾处匹配此集合中字符的实例都将被移除。
从末尾修剪后的字符串。如果输入字符串为 null 或 undefined,则返回空字符串。
console.log(trimEnd(" hello world ")); // -> " hello world"console.log(trimEnd("__hello__", "_")); // -> "__hello"console.log(trimEnd("-!-hello-!-", "-!")); // -> "-!-hello"console.log(trimEnd("/path/to/file/", "/")); // -> "/path/to/file"console.log(trimEnd(null)); // -> "" Copy
console.log(trimEnd(" hello world ")); // -> " hello world"console.log(trimEnd("__hello__", "_")); // -> "__hello"console.log(trimEnd("-!-hello-!-", "-!")); // -> "-!-hello"console.log(trimEnd("/path/to/file/", "/")); // -> "/path/to/file"console.log(trimEnd(null)); // -> ""
移除字符串末尾指定的字符。