更新时间:2023-02-04 23:18:41
为什么不使用子字符串... string.substring(0,7);
第一个参数(0)是起点。第二个参数(7)是结束点(不包括)。 此处提供更多信息。
Why not just use substring... string.substring(0, 7);
The first argument (0) is the starting point. The second argument (7) is the ending point (exclusive). More info here.
var string = "this is a string";
var length = 7;
var trimmedString = string.substring(0, length);