_.repeat

❗️Lodash onlyRepeats the given string n times.

  1. // Lodash
  2. var result = _.repeat('abc', 2)
  3. console.log(result)
  4. // output: 'abcabc'
  5.  
  6. // Native
  7. var result = 'abc'.repeat(2)
  8. console.log(result)
  9. // output: 'abcabc'

Browser Support for String.prototype.repeat()

ChromeEdgeFirefoxIEOperaSafari
41.0 ✔24.0 ✔28.0 ✔9.0 ✔