Repeat Character N Times

后端 未结 23 2543
栀梦
栀梦 2020-11-22 11:51

In Perl I can repeat a character multiple times using the syntax:

$a = \"a\" x 10; // results in \"aaaaaaaaaa\"

Is there a simple way to ac

23条回答
  •  逝去的感伤
    2020-11-22 12:22

    Lodash offers a similar functionality as the Javascript repeat() function which is not available in all browers. It is called _.repeat and available since version 3.0.0:

    _.repeat('a', 10);
    

提交回复
热议问题