ES6 - 新的字串方法 repeat()



此函式將指定的字串重複指定的次數。

語法

str.repeat(count)

引數

  • Count − 字串應重複的次數。

返回值

返回一個新字串。

示例

var myBook = new String("Perl"); 
console.log(myBook.repeat(2)); 

輸出

PerlPerl 
廣告

© . All rights reserved.