string.repeat
repeat() ๋ฉ์๋๋ ํธ์ถ๋ ๋ฌธ์์ด์์ ์ฌ๋ณธ์ด ํฌํจ. ์ฐ๊ฒฐํ์ฌ ์ง์ ๋ ํ์์ ์ ๋ฌธ์์ด์ ๊ตฌ์ฑํ๊ณ ๋ฐํํ๋ค.
const str = '๊ณ ์์ฐ ๋๋ฌด ๊ท์ฝ์ฐ ';
str.repeat(2); // "๊ณ ์์ฐ ๋๋ฌด ๊ท์ฝ์ฐ ๊ณ ์์ฐ ๋๋ฌด ๊ท์ฝ์ฐ "Syntax
str.repeat(count)Parameters
count
๋ฌธ์์ด์ ๋ฐ๋ณต ํ ํ์๋ฅผ ๋ํ๋ด๋ 0๊ณผ +Infinity ์ฌ์ด์ ์ ์
Return value
์ฃผ์ด์ง ๋ฌธ์์ด์ ์ง์ ๋ ์์ ์ฌ๋ณธ์ ํฌํจํ๋ ์๋ก์ด ๋ฌธ์์ด
Exceptions
RangeError: ๋ฐ๋ณต ํ์๋ ์์๊ฐ ์๋์ฌ์ผ ํ๋ค.RangeError: ๋ฐ๋ณต ํ์๋ ๋ฌดํ๋๋ณด๋ค ์์์ผํ๋ฉฐ ์ต๋ ๋ฌธ์์ด ํฌ๊ธฐ๋ฅผ ๋์ง ์์์ผ ํ๋ค.
Examples
Polyfill
repeat๋ ECMAScript 2015 ๋ช ์ธ์ ์ถ๊ฐ๋์๋ค.
Browser compatibility
IE ๋ ์๋๋ก์ด๋ ์น๋ทฐ ๋
Last updated
Was this helpful?