λ©μμ§
RangeError: repeat count must be non-negative (Firefox) RangeError: Invalid count value (Chrome)
μλ¬ νμ
무μμ΄ μλͺ»λμμκΉ?
String.prototype.repeat()
λ©μλκ° μ¬μ©λμμ΅λλ€. μ΄ λ©μλλ λ¬Έμμ΄μ΄ λ°λ³΅λλ μλ₯Ό μμΈ‘νλ μΉ΄μ΄νΈ νλΌλ©ν°λ₯Ό κ°μ§κ³ μμμ΅λλ€. μ΄ νλΌλ©ν°λ 0λ³΄λ€ ν¬κ³ , μμ Infinity
보λ€λ μμΌλ©°, μμλ λ μ μμ΅λλ€. μ΄ λ²μλ μ΄λ κ² νν λ μ μμ΅λλ€. : [0, +β)
μ
νμ©λμ§ μλ κ²½μ°
'abc'.repeat(-1); // RangeError
νμ©λλ κ²½μ°
'abc'.repeat(0); // ''
'abc'.repeat(1); // 'abc'
'abc'.repeat(2); // 'abcabc'
'abc'.repeat(3.5); // 'abcabcabc' (μλ μ μλ‘ λ³νλ κ²μ
λλ€.)