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