Does JavaScript have a built in stringbuilder class?

前端 未结 10 1608
Happy的楠姐
Happy的楠姐 2020-11-30 19:33

I see a few code project solutions.

But is there a regular implementation in JavaScript?

10条回答
  •  自闭症患者
    2020-11-30 20:32

    In C# you can do something like

     String.Format("hello {0}, your age is {1}.",  "John",  29) 
    

    In JavaScript you could do something like

     var x = "hello {0}, your age is {1}";
     x = x.replace(/\{0\}/g, "John");
     x = x.replace(/\{1\}/g, 29);
    

提交回复
热议问题