Are JavaScript strings immutable? Do I need a “string builder” in JavaScript?

后端 未结 10 2581
挽巷
挽巷 2020-11-22 02:48

Does javascript use immutable or mutable strings? Do I need a \"string builder\"?

10条回答
  •  星月不相逢
    2020-11-22 03:50

    Performance tip:

    If you have to concatenate large strings, put the string parts into an array and use the Array.Join() method to get the overall string. This can be many times faster for concatenating a large number of strings.

    There is no StringBuilder in JavaScript.

提交回复
热议问题