字符串方法中会修改原字符串_字符串padEnd()方法

字符串方法中会修改原字符串

The purpose of string padding is to add characters to a string, so it reaches a specific length.

字符串填充的目的是在字符串中添加字符 ,使其达到特定长度

padEnd(), introduced in ES2017, adds such characters at the end of the string.

padEnd()引入的padEnd()会在字符串的末尾添加此类字符。

padEnd(targetLength [, padString])

Sample usage:

用法示例:

padEnd()
‘test’.padEnd(4)‘test’
‘test’.padEnd(5)‘test ‘
‘test’.padEnd(8)‘test    ‘
‘test’.padEnd(8, ‘abcd’)‘testabcd’
padEnd()
'test'.padEnd(4)'测试'
'test'.padEnd(5)'测试'
'test'.padEnd(8)'测试'
'test'.padEnd(8,'abcd')'testabcd'

Also see padStart().

另请参见padStart()

翻译自: https://flaviocopes.com/javascript-string-padend/

字符串方法中会修改原字符串