repeat
方法返回一个新字符串,表示将原字符串重复n
次。
"abc".repeat(-1) // RangeError: repeat count must be positive and less than inifinity "abc".repeat(0) // "" "abc".repeat(1) // "abc" "abc".repeat(2) // "abcabc" "abc".repeat(3.5) // "abcabcabc" 参数count将会被自动转换成整数. "abc".repeat(1/0) // RangeError: repeat count must be positive and less than inifinity