aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/errors/negative_repetition_count/index.html
blob: b2437c9ad8469cd7c1cd21de7f10c153aee1767b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---
title: 'RangeError: repeat count must be non-negative'
slug: Web/JavaScript/Reference/Errors/Negative_repetition_count
translation_of: Web/JavaScript/Reference/Errors/Negative_repetition_count
---
<div>{{jsSidebar("Errors")}}</div>

<h2 id="메시지">메시지</h2>

<pre class="syntaxbox">RangeError: repeat count must be non-negative (Firefox)
RangeError: Invalid count value (Chrome)
</pre>

<h2 id="에러_형식">에러 형식</h2>

<p>{{jsxref("RangeError")}}</p>

<h2 id="무엇이_잘못되었을까">무엇이 잘못되었을까?</h2>

<p>{{jsxref("String.prototype.repeat()")}} 메소드가 사용되었습니다. 이 메소드는 문자열이 반복되는 수를 예측하는 카운트 파라메터를 가지고 있었습니다. 이 파라메터는 0보다 크고, 양의 {{jsxref("Infinity")}} 보다는 작으며, 음수는 될수 없습니다. 이 범위는 이렇게 표현 될 수 있습니다. : [0, +∞)</p>

<h2 id="예"></h2>

<h3 id="허용되지_않는_경우">허용되지 않는 경우</h3>

<pre class="brush: js example-bad">'abc'.repeat(-1); // RangeError </pre>

<h3 id="허용되는_경우">허용되는 경우</h3>

<pre class="brush: js example-good">'abc'.repeat(0);    // ''
'abc'.repeat(1);    // 'abc'
'abc'.repeat(2);    // 'abcabc'
'abc'.repeat(3.5);  // 'abcabcabc' (수는 정수로 변환될 것입니다.)
</pre>

<h2 id="참조">참조</h2>

<ul>
 <li>{{jsxref("String.prototype.repeat()")}}</li>
</ul>