728x90
repeat() 란?
repeat()는 문자열을 복사하여, 복사한 새로운 문자열을 반환해주는 메서드입니다.
const str1 = "cat"
const currentStr1 = str1.concat("0"); //'_' //공백
const currentStr2 = str1.concat("1"); //cat
const currentStr3 = str1.concat("3"); //catcatcat
"문자열".repeat(숫자)
const str1 = "javascript";
const currentStr1 = str1.repeat("0"); //''
const currentStr2 = str1.repeat("1"); //javascript
const currentStr3 = str1.repeat("2"); //javascriptjavascript
728x90
'Javascript' 카테고리의 다른 글
includes() (4) | 2022.08.17 |
---|---|
padStart() / padEnd() (4) | 2022.08.17 |
concat() (2) | 2022.08.17 |
replace() / replaceAll() (1) | 2022.08.17 |
split() (4) | 2022.08.17 |
댓글