Array Join vs String Concat

前端 未结 7 998
一向
一向 2020-11-29 03:14

Which method is faster?

Array Join:

var str_to_split = \"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z\";
var myarray = str_to         


        
7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 03:44

    The spread operator, written with three consecutive dots ( ... ), is new in ES6 and gives you the ability to expand, or spread, iterable objects into multiple elements.

    const books = ["Don Quixote", "The Hobbit", "Alice in Wonderland", "Tale of Two Cities"];
    console.log(...books);

    Prints: Don Quixote The Hobbit Alice in Wonderland Tale of Two Cities

提交回复
热议问题