0andme.github.io
0andme gitHub

String.repeat()

주어진 문자열을 반복 횟수만큼 반복하기
April 17, 2022
  1. js

String.prototype.repeat(cnt)

주어진 문자열을 cnt번 반복한 문자열을 반환한다. cnt값은 0이상의 무한대 사이의 양의 정수여야한다. [0,+∞)

✤ 기본 예제
"ABC".repeat(-1) // RangeError
"ABC".repeat(0) // ''
"ABC".repeat(1) // "ABC"
"ABC".repeat(3.5) // "ABCABCABC"

공식 문서


Profile picture