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