JS: String.prototype.repeat
(new in ECMAScript 2015)
String.prototype.repeat(count)-
repeat a string.
console.assert("a".repeat(2) === "aa"); The function can also work on Value Types othe than string. It will first convert this (binding) to string, then return
countcopy of it, joined together./* digit 9 to string, then repeat 2 times */ console.assert(Reflect.apply(String.prototype.repeat, 9, [2]) === "99"); [see JS: Reflect (namespace)]
JS String.prototype
- JS: String.prototype.constructor
- JS: String.prototype.length
- JS: String.prototype.at (extract char at index)
- JS: String.fromCharCode (id to char) ❌
- JS: String.prototype.concat
- JS: String.prototype.repeat
- JS: String.prototype.trim
- JS: String.prototype.trimStart
- JS: String.prototype.trimEnd
- JS: String.prototype.padStart
- JS: String.prototype.padEnd
- JS: String.prototype.slice
- JS: String.prototype.substring ❌
- JS: String.prototype.substr
- JS: String.prototype.indexOf
- JS: String.prototype.lastIndexOf
- JS: String.prototype.includes
- JS: String.prototype.startsWith
- JS: String.prototype.endsWith
- JS: String.prototype.search
- JS: String.prototype.match
- JS: String.prototype.matchAll
- JS: String.prototype.replace
- JS: String.prototype.split
- JS: String.prototype.toLowerCase
- JS: String.prototype.charAt (extract char at index) ❌
- JS: String.prototype.charCodeAt (char to id) ❌
- JS: String.prototype.codePointAt (char to id)