Angular2 or TypeScript Left padding a String with Zeros

后端 未结 7 1818
無奈伤痛
無奈伤痛 2020-12-16 09:42

I have a number let say 9. But I need it as String \"09\".

I know i can write my own logic. But I am looking for a implicit util function which can pad it.

I

7条回答
  •  太阳男子
    2020-12-16 10:29

    if i want to pad "0" at the start and want the length of the String str to be 9:

    str.padStart(9 ,"0")
    

提交回复
热议问题