What is the difference of + operator and concat() method in JavaScript

后端 未结 1 511
被撕碎了的回忆
被撕碎了的回忆 2021-02-12 17:19

The plus ( + ) operator and String.concat() method gives the same result.

plus ( + ) operator;

str1 + str2         


        
1条回答
  •  感动是毒
    2021-02-12 17:56

    There are pretty the same but + is more clear and for sure faster.

    Look at this performance test and also see this

    It is strongly recommended that assignment operators (+, +=) are used instead of the concat() method.

    0 讨论(0)
提交回复
热议问题