[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Errors/Negative_repetition_count [Back]  [Original]

RangeError: repeat count must be non-negative - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

RangeError: repeat count must be non-negative

RangeError: repeat count must be non-negative (Firefox)
RangeError: Invalid count value (Chrome)

In this article

RangeError

?

String.prototype.repeat(), count, . 0 Infinity, . : [0, + ).

js
"abc".repeat(-1); // RangeError

js
"abc".repeat(0); // ''
"abc".repeat(1); // 'abc'
"abc".repeat(2); // 'abcabc'
"abc".repeat(3.5); // 'abcabcabc' (count will be converted to integer)


Web Proxy Viewer  |  New URL  |  Original Page