2
1

More than 3 years have passed since last update.

JavaScriptで文字列のゼロパディング(C言語でいう%02d)

Last updated at Posted at 2020-12-12

padStart を使うとよいです。
第一引数で何桁まで埋めるか指定し、第二引数で埋める文字を指定します。


> '1'.padStart(2, '0')
  => "01"

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1