1.padStart(len, str)
根据给定长度自动在字符串的前面补充想补充的字符串(只返回修改后的字符串,不修改原字符串)
(1)len 给定的长度,转换后
(2)str 想补充的字符串
例如:
let a = '7'; a.padStart(3, '0'); // 007
2.padEnd(len, str)
只是把想加的字符串加到后头
(1)len 给定的长度,转换后
(2)str 想补充的字符串
例如:
let a = '7'; a.padEnd(3, '0'); // 700
.